use std::env;
+use std::cell::Cell;
use std::fs;
use std::io::{self, ErrorKind};
use std::path::{Path, PathBuf};
static CARGO_INTEGRATION_TEST_DIR : &'static str = "cit";
static NEXT_ID: AtomicUsize = ATOMIC_USIZE_INIT;
+
thread_local!(static TASK_ID: usize = NEXT_ID.fetch_add(1, Ordering::SeqCst));
-pub fn root() -> PathBuf {
+fn init() {
+ static GLOBAL_INIT: Once = ONCE_INIT;
+ thread_local!(static LOCAL_INIT: Cell<bool> = Cell::new(false));
+ GLOBAL_INIT.call_once(|| {
+ global_root().mkdir_p().unwrap();
+ });
+ LOCAL_INIT.with(|i| {
+ if i.get() {
+ return
+ }
+ i.set(true);
+ root().rm_rf().unwrap();
+ home().mkdir_p().unwrap();
+ })
+}
+
+fn global_root() -> PathBuf {
let mut path = env::current_exe().unwrap();
path.pop(); // chop off exe name
path.pop(); // chop off 'debug'
}
path.join(CARGO_INTEGRATION_TEST_DIR)
- .join(&TASK_ID.with(|my_id| format!("t{}", my_id)))
+}
+
+pub fn root() -> PathBuf {
+ init();
+ global_root().join(&TASK_ID.with(|my_id| format!("t{}", my_id)))
}
pub fn home() -> PathBuf {
fs::metadata(self)
}
}
-
-/// Ensure required test directories exist and are empty
-pub fn setup() {
- debug!("path setup; root={}; home={}", root().display(), home().display());
- static INIT: Once = ONCE_INIT;
- INIT.call_once(|| {
- root().parent().unwrap().mkdir_p().unwrap();
- });
- root().rm_rf().unwrap();
- home().mkdir_p().unwrap();
-}
use support::registry::Package;
use hamcrest::assert_that;
-fn setup() {}
-
-test!(bad1 {
+#[test]
+fn bad1() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
[ERROR] expected table for configuration key `target.nonexistent-target`, \
but found string in [..]config
"));
-});
+}
-test!(bad2 {
+#[test]
+fn bad2() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
found TOML configuration value of unknown type `float`
"));
-});
+}
-test!(bad3 {
+#[test]
+fn bad3() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
[ERROR] invalid configuration for key `http.proxy`
expected a string, but found a boolean in [..]config
"));
-});
+}
-test!(bad4 {
+#[test]
+fn bad4() {
let foo = project("foo")
.file(".cargo/config", r#"
[cargo-new]
invalid configuration for key `cargo-new.name`
expected a string, but found a boolean in [..]config
"));
-});
+}
-test!(bad5 {
+#[test]
+fn bad5() {
let foo = project("foo")
.file(".cargo/config", r#"
foo = ""
Caused by:
expected integer, but found string
"));
-});
+}
-test!(bad_cargo_config_jobs {
+#[test]
+fn bad_cargo_config_jobs() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101).with_stderr("\
[ERROR] build.jobs must be positive, but found -1 in [..]
"));
-});
+}
-test!(default_cargo_config_jobs {
+#[test]
+fn default_cargo_config_jobs() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
"#);
assert_that(foo.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(good_cargo_config_jobs {
+#[test]
+fn good_cargo_config_jobs() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
"#);
assert_that(foo.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(invalid_global_config {
+#[test]
+fn invalid_global_config() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
[..]config:1:2 expected `=`, but found eof
"));
-});
+}
-test!(bad_cargo_lock {
+#[test]
+fn bad_cargo_lock() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
expected a section for the key `root`
"));
-});
+}
-test!(bad_git_dependency {
+#[test]
+fn bad_git_dependency() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
[[..]] 'file:///' is not a valid local file URI
"));
-});
+}
-test!(bad_crate_type {
+#[test]
+fn bad_crate_type() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
[COMPILING] foo v0.0.0 (file:///[..])
[RUNNING] `rustc [..] --crate-type rlib [..]`
"));
-});
+}
-test!(malformed_override {
+#[test]
+fn malformed_override() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Cargo.toml:[..]
"));
-});
+}
-test!(duplicate_binary_names {
+#[test]
+fn duplicate_binary_names() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
found duplicate binary name e, but all binary targets must have a unique name
"));
-});
+}
-test!(duplicate_example_names {
+#[test]
+fn duplicate_example_names() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
found duplicate example name ex, but all binary targets must have a unique name
"));
-});
+}
-test!(duplicate_bench_names {
+#[test]
+fn duplicate_bench_names() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
found duplicate bench name ex, but all binary targets must have a unique name
"));
-});
+}
-test!(duplicate_deps {
+#[test]
+fn duplicate_deps() {
let foo = project("foo")
.file("shim-bar/Cargo.toml", r#"
[package]
Caused by:
found duplicate dependency name bar, but all dependencies must have a unique name
"));
-});
+}
-test!(unused_keys {
+#[test]
+fn unused_keys() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
warning: unused manifest key: target.foo.bar
[COMPILING] foo v0.1.0 (file:///[..])
"));
-});
+}
-test!(empty_dependencies {
+#[test]
+fn empty_dependencies() {
let p = project("empty_deps")
.file("Cargo.toml", r#"
[package]
warning: dependency (foo) specified without providing a local path, Git repository, or version \
to use. This will be considered an error in future versions
"));
-});
+}
use support::{project, execs, main_file, basic_bin_manifest};
use hamcrest::{assert_that};
-fn setup() {}
-
fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
));
}
-test!(bench_dir_containing_cargo_toml {
+#[test]
+fn bench_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("bench", "foo");
-});
+}
-test!(bench_dir_plus_file {
+#[test]
+fn bench_dir_plus_file() {
assert_not_a_cargo_toml("bench", "foo/bar");
-});
+}
-test!(bench_dir_plus_path {
+#[test]
+fn bench_dir_plus_path() {
assert_not_a_cargo_toml("bench", "foo/bar/baz");
-});
+}
-test!(bench_dir_to_nonexistent_cargo_toml {
+#[test]
+fn bench_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("bench", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(build_dir_containing_cargo_toml {
+#[test]
+fn build_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("build", "foo");
-});
+}
-test!(build_dir_plus_file {
+#[test]
+fn build_dir_plus_file() {
assert_not_a_cargo_toml("bench", "foo/bar");
-});
+}
-test!(build_dir_plus_path {
+#[test]
+fn build_dir_plus_path() {
assert_not_a_cargo_toml("bench", "foo/bar/baz");
-});
+}
-test!(build_dir_to_nonexistent_cargo_toml {
+#[test]
+fn build_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("build", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(clean_dir_containing_cargo_toml {
+#[test]
+fn clean_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("clean", "foo");
-});
+}
-test!(clean_dir_plus_file {
+#[test]
+fn clean_dir_plus_file() {
assert_not_a_cargo_toml("clean", "foo/bar");
-});
+}
-test!(clean_dir_plus_path {
+#[test]
+fn clean_dir_plus_path() {
assert_not_a_cargo_toml("clean", "foo/bar/baz");
-});
+}
-test!(clean_dir_to_nonexistent_cargo_toml {
+#[test]
+fn clean_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("clean", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(doc_dir_containing_cargo_toml {
+#[test]
+fn doc_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("doc", "foo");
-});
+}
-test!(doc_dir_plus_file {
+#[test]
+fn doc_dir_plus_file() {
assert_not_a_cargo_toml("doc", "foo/bar");
-});
+}
-test!(doc_dir_plus_path {
+#[test]
+fn doc_dir_plus_path() {
assert_not_a_cargo_toml("doc", "foo/bar/baz");
-});
+}
-test!(doc_dir_to_nonexistent_cargo_toml {
+#[test]
+fn doc_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("doc", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(fetch_dir_containing_cargo_toml {
+#[test]
+fn fetch_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("fetch", "foo");
-});
+}
-test!(fetch_dir_plus_file {
+#[test]
+fn fetch_dir_plus_file() {
assert_not_a_cargo_toml("fetch", "foo/bar");
-});
+}
-test!(fetch_dir_plus_path {
+#[test]
+fn fetch_dir_plus_path() {
assert_not_a_cargo_toml("fetch", "foo/bar/baz");
-});
+}
-test!(fetch_dir_to_nonexistent_cargo_toml {
+#[test]
+fn fetch_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("fetch", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(generate_lockfile_dir_containing_cargo_toml {
+#[test]
+fn generate_lockfile_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("generate-lockfile", "foo");
-});
+}
-test!(generate_lockfile_dir_plus_file {
+#[test]
+fn generate_lockfile_dir_plus_file() {
assert_not_a_cargo_toml("generate-lockfile", "foo/bar");
-});
+}
-test!(generate_lockfile_dir_plus_path {
+#[test]
+fn generate_lockfile_dir_plus_path() {
assert_not_a_cargo_toml("generate-lockfile", "foo/bar/baz");
-});
+}
-test!(generate_lockfile_dir_to_nonexistent_cargo_toml {
+#[test]
+fn generate_lockfile_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("generate-lockfile", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(package_dir_containing_cargo_toml {
+#[test]
+fn package_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("package", "foo");
-});
+}
-test!(package_dir_plus_file {
+#[test]
+fn package_dir_plus_file() {
assert_not_a_cargo_toml("package", "foo/bar");
-});
+}
-test!(package_dir_plus_path {
+#[test]
+fn package_dir_plus_path() {
assert_not_a_cargo_toml("package", "foo/bar/baz");
-});
+}
-test!(package_dir_to_nonexistent_cargo_toml {
+#[test]
+fn package_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("package", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(pkgid_dir_containing_cargo_toml {
+#[test]
+fn pkgid_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("pkgid", "foo");
-});
+}
-test!(pkgid_dir_plus_file {
+#[test]
+fn pkgid_dir_plus_file() {
assert_not_a_cargo_toml("pkgid", "foo/bar");
-});
+}
-test!(pkgid_dir_plus_path {
+#[test]
+fn pkgid_dir_plus_path() {
assert_not_a_cargo_toml("pkgid", "foo/bar/baz");
-});
+}
-test!(pkgid_dir_to_nonexistent_cargo_toml {
+#[test]
+fn pkgid_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("pkgid", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(publish_dir_containing_cargo_toml {
+#[test]
+fn publish_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("publish", "foo");
-});
+}
-test!(publish_dir_plus_file {
+#[test]
+fn publish_dir_plus_file() {
assert_not_a_cargo_toml("publish", "foo/bar");
-});
+}
-test!(publish_dir_plus_path {
+#[test]
+fn publish_dir_plus_path() {
assert_not_a_cargo_toml("publish", "foo/bar/baz");
-});
+}
-test!(publish_dir_to_nonexistent_cargo_toml {
+#[test]
+fn publish_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("publish", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(read_manifest_dir_containing_cargo_toml {
+#[test]
+fn read_manifest_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("read-manifest", "foo");
-});
+}
-test!(read_manifest_dir_plus_file {
+#[test]
+fn read_manifest_dir_plus_file() {
assert_not_a_cargo_toml("read-manifest", "foo/bar");
-});
+}
-test!(read_manifest_dir_plus_path {
+#[test]
+fn read_manifest_dir_plus_path() {
assert_not_a_cargo_toml("read-manifest", "foo/bar/baz");
-});
+}
-test!(read_manifest_dir_to_nonexistent_cargo_toml {
+#[test]
+fn read_manifest_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("read-manifest", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(run_dir_containing_cargo_toml {
+#[test]
+fn run_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("run", "foo");
-});
+}
-test!(run_dir_plus_file {
+#[test]
+fn run_dir_plus_file() {
assert_not_a_cargo_toml("run", "foo/bar");
-});
+}
-test!(run_dir_plus_path {
+#[test]
+fn run_dir_plus_path() {
assert_not_a_cargo_toml("run", "foo/bar/baz");
-});
+}
-test!(run_dir_to_nonexistent_cargo_toml {
+#[test]
+fn run_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("run", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(rustc_dir_containing_cargo_toml {
+#[test]
+fn rustc_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("rustc", "foo");
-});
+}
-test!(rustc_dir_plus_file {
+#[test]
+fn rustc_dir_plus_file() {
assert_not_a_cargo_toml("rustc", "foo/bar");
-});
+}
-test!(rustc_dir_plus_path {
+#[test]
+fn rustc_dir_plus_path() {
assert_not_a_cargo_toml("rustc", "foo/bar/baz");
-});
+}
-test!(rustc_dir_to_nonexistent_cargo_toml {
+#[test]
+fn rustc_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("rustc", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(test_dir_containing_cargo_toml {
+#[test]
+fn test_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("test", "foo");
-});
+}
-test!(test_dir_plus_file {
+#[test]
+fn test_dir_plus_file() {
assert_not_a_cargo_toml("test", "foo/bar");
-});
+}
-test!(test_dir_plus_path {
+#[test]
+fn test_dir_plus_path() {
assert_not_a_cargo_toml("test", "foo/bar/baz");
-});
+}
-test!(test_dir_to_nonexistent_cargo_toml {
+#[test]
+fn test_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("test", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(update_dir_containing_cargo_toml {
+#[test]
+fn update_dir_containing_cargo_toml() {
assert_not_a_cargo_toml("update", "foo");
-});
+}
-test!(update_dir_plus_file {
+#[test]
+fn update_dir_plus_file() {
assert_not_a_cargo_toml("update", "foo/bar");
-});
+}
-test!(update_dir_plus_path {
+#[test]
+fn update_dir_plus_path() {
assert_not_a_cargo_toml("update", "foo/bar/baz");
-});
+}
-test!(update_dir_to_nonexistent_cargo_toml {
+#[test]
+fn update_dir_to_nonexistent_cargo_toml() {
assert_cargo_toml_doesnt_exist("update", "foo/bar/baz/Cargo.toml");
-});
+}
-test!(verify_project_dir_containing_cargo_toml {
+#[test]
+fn verify_project_dir_containing_cargo_toml() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.with_stdout("\
{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
"));
-});
+}
-test!(verify_project_dir_plus_file {
+#[test]
+fn verify_project_dir_plus_file() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.with_stdout("\
{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
"));
-});
+}
-test!(verify_project_dir_plus_path {
+#[test]
+fn verify_project_dir_plus_path() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.with_stdout("\
{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
"));
-});
+}
-test!(verify_project_dir_to_nonexistent_cargo_toml {
+#[test]
+fn verify_project_dir_to_nonexistent_cargo_toml() {
let p = project("foo");
assert_that(p.cargo_process("verify-project")
.arg("--manifest-path").arg("foo/bar/baz/Cargo.toml")
.with_stdout("\
{\"invalid\":\"manifest path `foo[..]bar[..]baz[..]Cargo.toml` does not exist\"}\
"));
-});
+}
use support::{execs, project, mkdir_recursive, ProjectBuilder};
use hamcrest::{assert_that};
-fn setup() {
-}
-
#[cfg_attr(windows,allow(dead_code))]
enum FakeKind<'a> {
Executable,
env::split_paths(&env::var_os("PATH").unwrap_or(OsString::new())).collect()
}
-test!(list_command_looks_at_path {
+#[test]
+fn list_command_looks_at_path() {
let proj = project("list-non-overlapping");
let proj = fake_file(proj, &Path::new("path-test"), "cargo-1", FakeKind::Executable);
let mut pr = cargo_process();
let output = output.exec_with_output().unwrap();
let output = str::from_utf8(&output.stdout).unwrap();
assert!(output.contains("\n 1\n"), "missing 1: {}", output);
-});
+}
// windows and symlinks don't currently agree that well
#[cfg(unix)]
-test!(list_command_resolves_symlinks {
+#[test]
+fn list_command_resolves_symlinks() {
use support::cargo_dir;
let proj = project("list-non-overlapping");
let output = output.exec_with_output().unwrap();
let output = str::from_utf8(&output.stdout).unwrap();
assert!(output.contains("\n 2\n"), "missing 2: {}", output);
-});
+}
-test!(find_closest_biuld_to_build {
+#[test]
+fn find_closest_biuld_to_build() {
let mut pr = cargo_process();
pr.arg("biuld");
<tab>Did you mean `build`?
"));
-});
+}
// if a subcommand is more than 3 edit distance away, we don't make a suggestion
-test!(find_closest_dont_correct_nonsense {
+#[test]
+fn find_closest_dont_correct_nonsense() {
let mut pr = cargo_process();
pr.arg("there-is-no-way-that-there-is-a-command-close-to-this")
.cwd(&paths::root());
execs().with_status(101)
.with_stderr("[ERROR] no such subcommand
"));
-});
+}
-test!(override_cargo_home {
+#[test]
+fn override_cargo_home() {
let root = paths::root();
let my_home = root.join("my_home");
fs::create_dir(&my_home).unwrap();
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["foo <bar>"]"#));
-});
+}
-test!(cargo_help {
+#[test]
+fn cargo_help() {
assert_that(cargo_process(),
execs().with_status(0));
assert_that(cargo_process().arg("help"),
execs().with_status(0));
assert_that(cargo_process().arg("help").arg("help"),
execs().with_status(0));
-});
+}
-test!(explain {
+#[test]
+fn explain() {
assert_that(cargo_process().arg("--explain").arg("E0001"),
execs().with_status(0));
-});
+}
use hamcrest::{assert_that, existing_file};
use cargo::util::process;
-fn setup() {}
-
-test!(cargo_bench_simple {
+#[test]
+fn cargo_bench_simple() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(bench_tarname {
+#[test]
+fn bench_tarname() {
if !::is_nightly() { return }
let prj = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(cargo_bench_verbose {
+#[test]
+fn cargo_bench_verbose() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(many_similar_names {
+#[test]
+fn many_similar_names() {
if !::is_nightly() { return }
let p = project("foo")
assert!(output.contains("test bin_bench"), "bin_bench missing\n{}", output);
assert!(output.contains("test lib_bench"), "lib_bench missing\n{}", output);
assert!(output.contains("test bench_bench"), "bench_bench missing\n{}", output);
-});
+}
-test!(cargo_bench_failing_test {
+#[test]
+fn cargo_bench_failing_test() {
if !::is_nightly() { return }
let p = project("foo")
[..]
", p.url()))
.with_status(101));
-});
+}
-test!(bench_with_lib_dep {
+#[test]
+fn bench_with_lib_dep() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"))
-});
+}
-test!(bench_with_deep_lib_dep {
+#[test]
+fn bench_with_deep_lib_dep() {
if !::is_nightly() { return }
let p = project("bar")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(external_bench_explicit {
+#[test]
+fn external_bench_explicit() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"))
-});
+}
-test!(external_bench_implicit {
+#[test]
+fn external_bench_implicit() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"))
-});
+}
-test!(dont_run_examples {
+#[test]
+fn dont_run_examples() {
if !::is_nightly() { return }
let p = project("foo")
"#);
assert_that(p.cargo_process("bench"),
execs().with_status(0));
-});
+}
-test!(pass_through_command_line {
+#[test]
+fn pass_through_command_line() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
// Regression test for running cargo-bench twice with
// tests in an rlib
-test!(cargo_bench_twice {
+#[test]
+fn cargo_bench_twice() {
if !::is_nightly() { return }
let p = project("test_twice")
assert_that(p.cargo("bench"),
execs().with_status(0));
}
-});
+}
-test!(lib_bin_same_name {
+#[test]
+fn lib_bin_same_name() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"))
-});
+}
-test!(lib_with_standard_name {
+#[test]
+fn lib_with_standard_name() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(lib_with_standard_name2 {
+#[test]
+fn lib_with_standard_name2() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(bench_dylib {
+#[test]
+fn bench_dylib() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(bench_twice_with_build_cmd {
+#[test]
+fn bench_twice_with_build_cmd() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(bench_with_examples {
+#[test]
+fn bench_with_examples() {
if !::is_nightly() { return }
let p = project("testbench")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
-test!(test_a_bench {
+#[test]
+fn test_a_bench() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(test_bench_no_run {
+#[test]
+fn test_bench_no_run() {
if !::is_nightly() { return }
let p = project("foo")
.with_stderr("\
[COMPILING] foo v0.1.0 ([..])
"));
-});
+}
-test!(test_bench_multiple_packages {
+#[test]
+fn test_bench_multiple_packages() {
if !::is_nightly() { return }
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
"));
-});
+}
use support::paths;
use hamcrest::assert_that;
-fn setup() {
-}
-
// Test that HTTP auth is offered from `credential.helper`
-test!(http_auth_offered {
+#[test]
+fn http_auth_offered() {
let a = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = a.local_addr().unwrap();
addr = addr)));
t.join().ok().unwrap();
-});
+}
// Boy, sure would be nice to have a TLS implementation in rust!
-test!(https_something_happens {
+#[test]
+fn https_something_happens() {
let a = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = a.local_addr().unwrap();
let t = thread::spawn(move|| {
})));
t.join().ok().unwrap();
-});
+}
// Boy, sure would be nice to have an SSH implementation in rust!
-test!(ssh_something_happens {
+#[test]
+fn ssh_something_happens() {
let a = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = a.local_addr().unwrap();
let t = thread::spawn(move|| {
[[..]] Failed to start SSH session: Failed getting banner
"));
t.join().ok().unwrap();
-});
+}
use support::{basic_bin_manifest, execs, project, ProjectBuilder};
use hamcrest::{assert_that};
-fn setup() {
-}
-
fn verbose_output_for_lib(p: &ProjectBuilder) -> String {
format!("\
[COMPILING] {name} v{version} ({url})
name = "foo", version = "0.0.1")
}
-test!(build_lib_only {
+#[test]
+fn build_lib_only() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs()
.with_status(0)
.with_stderr(verbose_output_for_lib(&p)));
-});
+}
-test!(build_with_no_lib {
+#[test]
+fn build_with_no_lib() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", r#"
assert_that(p.cargo_process("build").arg("--lib"),
execs().with_status(101)
.with_stderr("[ERROR] no library targets found"));
-});
+}
-test!(build_with_relative_cargo_home_path {
+#[test]
+fn build_with_relative_cargo_home_path() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build").env("CARGO_HOME", "./cargo_home/"),
execs()
.with_status(0));
-});
+}
assert!(!e!(any((not(foo)), (all(foo, bar)))).matches(&[c!(foo)]));
}
-fn setup() {}
-
-test!(cfg_easy {
+#[test]
+fn cfg_easy() {
if !::is_nightly() { return }
let p = project("foo")
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(dont_include {
+#[test]
+fn dont_include() {
if !::is_nightly() { return }
let other_family = if cfg!(unix) {"windows"} else {"unix"};
execs().with_status(0).with_stderr("\
[COMPILING] a v0.0.1 ([..])
"));
-});
+}
-test!(works_through_the_registry {
+#[test]
+fn works_through_the_registry() {
if !::is_nightly() { return }
Package::new("foo", "0.1.0").publish();
[COMPILING] bar v0.1.0 ([..])
[COMPILING] a v0.0.1 ([..])
"));
-});
+}
-test!(bad_target_spec {
+#[test]
+fn bad_target_spec() {
let p = project("a")
.file("Cargo.toml", &r#"
[package]
Caused by:
unexpected character in cfg `4`, [..]
"));
-});
+}
-test!(bad_target_spec2 {
+#[test]
+fn bad_target_spec2() {
let p = project("a")
.file("Cargo.toml", &r#"
[package]
Caused by:
expected a string, found nothing
"));
-});
+}
-test!(multiple_match_ok {
+#[test]
+fn multiple_match_ok() {
if !::is_nightly() { return }
let p = project("foo")
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(any_ok {
+#[test]
+fn any_ok() {
if !::is_nightly() { return }
let p = project("foo")
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
use support::registry::Package;
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
-fn setup() {
-}
-
-test!(cargo_clean_simple {
+#[test]
+fn cargo_clean_simple() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
assert_that(p.cargo("clean"),
execs().with_status(0));
assert_that(&p.build_dir(), is_not(existing_dir()));
-});
+}
-test!(different_dir {
+#[test]
+fn different_dir() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
assert_that(p.cargo("clean").cwd(&p.root().join("src")),
execs().with_status(0).with_stdout(""));
assert_that(&p.build_dir(), is_not(existing_dir()));
-});
+}
-test!(clean_multiple_packages {
+#[test]
+fn clean_multiple_packages() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.bin("foo"), existing_file());
assert_that(d1_path, is_not(existing_file()));
assert_that(d2_path, is_not(existing_file()));
-});
+}
-test!(clean_release {
+#[test]
+fn clean_release() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.0.1 ([..])
"));
-});
+}
-test!(build_script {
+#[test]
+fn build_script() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[RUNNING] `[..]build-script-build[..]`
[RUNNING] `rustc src[..]main.rs [..]`
"));
-});
+}
-test!(clean_git {
+#[test]
+fn clean_git() {
let git = git::new("dep", |project| {
project.file("Cargo.toml", r#"
[project]
execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(registry {
+#[test]
+fn registry() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
use support::paths::{CargoPathExt,root};
use cargo::util::process;
-fn setup() {
-}
-
-test!(cargo_compile_simple {
+#[test]
+fn cargo_compile_simple() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
assert_that(process(&p.bin("foo")),
execs().with_stdout("i am foo\n"));
-});
+}
-test!(cargo_compile_manifest_path {
+#[test]
+fn cargo_compile_manifest_path() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root().parent().unwrap()),
execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
-});
+}
-test!(cargo_compile_with_invalid_manifest {
+#[test]
+fn cargo_compile_with_invalid_manifest() {
let p = project("foo")
.file("Cargo.toml", "");
Caused by:
no `package` or `project` section found.
"))
-});
+}
-test!(cargo_compile_with_invalid_manifest2 {
+#[test]
+fn cargo_compile_with_invalid_manifest2() {
let p = project("foo")
.file("Cargo.toml", r"
[project]
Cargo.toml:3:19-3:20 expected a value
"))
-});
+}
-test!(cargo_compile_with_invalid_manifest3 {
+#[test]
+fn cargo_compile_with_invalid_manifest3() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
could not parse input as TOML\n\
src[..]Cargo.toml:1:5-1:6 expected a value\n\n"))
-});
+}
-test!(cargo_compile_with_invalid_version {
+#[test]
+fn cargo_compile_with_invalid_version() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
cannot parse '1.0' as a semver for the key `project.version`
"))
-});
+}
-test!(cargo_compile_with_invalid_package_name {
+#[test]
+fn cargo_compile_with_invalid_package_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
package name cannot be an empty string.
"))
-});
+}
-test!(cargo_compile_with_invalid_bin_target_name {
+#[test]
+fn cargo_compile_with_invalid_bin_target_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
binary target names cannot be empty.
"))
-});
+}
-test!(cargo_compile_with_forbidden_bin_target_name {
+#[test]
+fn cargo_compile_with_forbidden_bin_target_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
the binary target name `build` is forbidden
"))
-});
+}
-test!(cargo_compile_with_invalid_lib_target_name {
+#[test]
+fn cargo_compile_with_invalid_lib_target_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
library target names cannot be empty.
"))
-});
+}
-test!(cargo_compile_without_manifest {
+#[test]
+fn cargo_compile_without_manifest() {
let tmpdir = TempDir::new("cargo").unwrap();
let p = ProjectBuilder::new("foo", tmpdir.path().to_path_buf());
.with_stderr("\
[ERROR] could not find `Cargo.toml` in `[..]` or any parent directory
"));
-});
+}
-test!(cargo_compile_with_invalid_code {
+#[test]
+fn cargo_compile_with_invalid_code() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", "invalid rust code!");
To learn more, run the command again with --verbose.\n"));
assert_that(&p.root().join("Cargo.lock"), existing_file());
-});
+}
-test!(cargo_compile_with_invalid_code_in_deps {
+#[test]
+fn cargo_compile_with_invalid_code_in_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
bar.build();
baz.build();
assert_that(p.cargo_process("build"), execs().with_status(101));
-});
+}
-test!(cargo_compile_with_warnings_in_the_root_package {
+#[test]
+fn cargo_compile_with_warnings_in_the_root_package() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", "fn main() {} fn dead() {}");
src[..]foo.rs:1 fn main() {} fn dead() {}
[..] ^~~~~~~~~~~~
"));
-});
+}
-test!(cargo_compile_with_warnings_in_a_dep_package {
+#[test]
+fn cargo_compile_with_warnings_in_a_dep_package() {
let mut p = project("foo");
p = p
assert_that(
process(&p.bin("foo")),
execs().with_stdout("test passed\n"));
-});
+}
-test!(cargo_compile_with_nested_deps_inferred {
+#[test]
+fn cargo_compile_with_nested_deps_inferred() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(
process(&p.bin("foo")),
execs().with_stdout("test passed\n"));
-});
+}
-test!(cargo_compile_with_nested_deps_correct_bin {
+#[test]
+fn cargo_compile_with_nested_deps_correct_bin() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(
process(&p.bin("foo")),
execs().with_stdout("test passed\n"));
-});
+}
-test!(cargo_compile_with_nested_deps_shorthand {
+#[test]
+fn cargo_compile_with_nested_deps_shorthand() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(
process(&p.bin("foo")),
execs().with_stdout("test passed\n"));
-});
+}
-test!(cargo_compile_with_nested_deps_longhand {
+#[test]
+fn cargo_compile_with_nested_deps_longhand() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(process(&p.bin("foo")),
execs().with_stdout("test passed\n"));
-});
+}
// Check that Cargo gives a sensible error if a dependency can't be found
// because of a name mismatch.
-test!(cargo_compile_with_dep_name_mismatch {
+#[test]
+fn cargo_compile_with_dep_name_mismatch() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
location searched: {proj_dir}/bar
version required: *
"#, proj_dir = p.url())));
-});
+}
-test!(cargo_compile_with_filename{
+#[test]
+fn cargo_compile_with_filename() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] no example target named `a.rs`
Did you mean `a`?"));
-});
+}
-test!(compile_path_dep_then_change_version {
+#[test]
+fn compile_path_dep_then_change_version() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
versions found: 0.0.2
consider running `cargo update` to update a path dependency's locked version
"));
-});
+}
-test!(ignores_carriage_return_in_lockfile {
+#[test]
+fn ignores_carriage_return_in_lockfile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
File::create(&lockfile).unwrap().write_all(lock.as_bytes()).unwrap();
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(crate_env_vars {
+#[test]
+fn crate_env_vars() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
println!("test");
assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
-});
+}
-test!(crate_authors_env_vars {
+#[test]
+fn crate_authors_env_vars() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
println!("test");
assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
-});
+}
// this is testing that src/<pkg-name>.rs still works (for now)
-test!(many_crate_types_old_style_lib_location {
+#[test]
+fn many_crate_types_old_style_lib_location() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
let fname = format!("{}foo{}", env::consts::DLL_PREFIX,
env::consts::DLL_SUFFIX);
assert_that(&p.root().join("target/debug").join(&fname), existing_file());
-});
+}
-test!(many_crate_types_correct {
+#[test]
+fn many_crate_types_correct() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
let fname = format!("{}foo{}", env::consts::DLL_PREFIX,
env::consts::DLL_SUFFIX);
assert_that(&p.root().join("target/debug").join(&fname), existing_file());
-});
+}
-test!(unused_keys {
+#[test]
+fn unused_keys() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
warning: unused manifest key: lib.build
[COMPILING] foo [..]
"));
-});
+}
-test!(self_dependency {
+#[test]
+fn self_dependency() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
.with_stderr("\
[ERROR] cyclic package dependency: package `test v0.0.0 ([..])` depends on itself
"));
-});
+}
-test!(ignore_broken_symlinks {
+#[test]
+fn ignore_broken_symlinks() {
// windows and symlinks don't currently agree that well
if cfg!(windows) { return }
assert_that(process(&p.bin("foo")),
execs().with_stdout("i am foo\n"));
-});
+}
-test!(missing_lib_and_bin {
+#[test]
+fn missing_lib_and_bin() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n"));
-});
+}
-test!(lto_build {
+#[test]
+fn lto_build() {
// FIXME: currently this hits a linker bug on 32-bit MSVC
if cfg!(all(target_env = "msvc", target_pointer_width = "32")) {
return
dir = p.root().display(),
url = p.url(),
)));
-});
+}
-test!(verbose_build {
+#[test]
+fn verbose_build() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
dir = p.root().display(),
url = p.url(),
)));
-});
+}
-test!(verbose_release_build {
+#[test]
+fn verbose_release_build() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
dir = p.root().display(),
url = p.url(),
)));
-});
+}
-test!(verbose_release_build_deps {
+#[test]
+fn verbose_release_build_deps() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
url = p.url(),
prefix = env::consts::DLL_PREFIX,
suffix = env::consts::DLL_SUFFIX)));
-});
+}
-test!(explicit_examples {
+#[test]
+fn explicit_examples() {
let mut p = project("world");
p = p.file("Cargo.toml", r#"
[package]
execs().with_stdout("Hello, World!\n"));
assert_that(process(&p.bin("examples/goodbye")),
execs().with_stdout("Goodbye, World!\n"));
-});
+}
-test!(implicit_examples {
+#[test]
+fn implicit_examples() {
let mut p = project("world");
p = p.file("Cargo.toml", r#"
[package]
execs().with_stdout("Hello, World!\n"));
assert_that(process(&p.bin("examples/goodbye")),
execs().with_stdout("Goodbye, World!\n"));
-});
+}
-test!(standard_build_no_ndebug {
+#[test]
+fn standard_build_no_ndebug() {
let p = project("world")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", r#"
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(&p.bin("foo")),
execs().with_stdout("slow\n"));
-});
+}
-test!(release_build_ndebug {
+#[test]
+fn release_build_ndebug() {
let p = project("world")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", r#"
execs().with_status(0));
assert_that(process(&p.release_bin("foo")),
execs().with_stdout("fast\n"));
-});
+}
-test!(inferred_main_bin {
+#[test]
+fn inferred_main_bin() {
let p = project("world")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(&p.bin("foo")), execs().with_status(0));
-});
+}
-test!(deletion_causes_failure {
+#[test]
+fn deletion_causes_failure() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
authors = []
"#);
assert_that(p.cargo_process("build"), execs().with_status(101));
-});
+}
-test!(bad_cargo_toml_in_target_dir {
+#[test]
+fn bad_cargo_toml_in_target_dir() {
let p = project("world")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(&p.bin("foo")), execs().with_status(0));
-});
+}
-test!(lib_with_standard_name {
+#[test]
+fn lib_with_standard_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[COMPILING] syntax v0.0.1 ({dir})
",
dir = p.url())));
-});
+}
-test!(simple_staticlib {
+#[test]
+fn simple_staticlib() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
// env var is a test for #1381
assert_that(p.cargo_process("build").env("RUST_LOG", "nekoneko=trace"),
execs().with_status(0));
-});
+}
-test!(staticlib_rlib_and_bin {
+#[test]
+fn staticlib_rlib_and_bin() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
}"#);
assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
-});
+}
-test!(opt_out_of_bin {
+#[test]
+fn opt_out_of_bin() {
let p = project("foo")
.file("Cargo.toml", r#"
bin = []
.file("src/lib.rs", "")
.file("src/main.rs", "bad syntax");
assert_that(p.cargo_process("build"), execs().with_status(0));
-});
+}
-test!(single_lib {
+#[test]
+fn single_lib() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
"#)
.file("src/bar.rs", "");
assert_that(p.cargo_process("build"), execs().with_status(0));
-});
+}
-test!(freshness_ignores_excluded {
+#[test]
+fn freshness_ignores_excluded() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(foo.cargo("build"),
execs().with_status(0)
.with_stdout(""));
-});
+}
-test!(rebuild_preserves_out_dir {
+#[test]
+fn rebuild_preserves_out_dir() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
.with_stderr(&format!("\
[COMPILING] foo v0.0.0 ({url})
", url = foo.url())));
-});
+}
-test!(dep_no_libs {
+#[test]
+fn dep_no_libs() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
.file("bar/src/main.rs", "");
assert_that(foo.cargo_process("build"),
execs().with_status(0));
-});
+}
-test!(recompile_space_in_name {
+#[test]
+fn recompile_space_in_name() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
foo.root().move_into_the_past().unwrap();
assert_that(foo.cargo("build"),
execs().with_status(0).with_stdout(""));
-});
+}
#[cfg(unix)]
-test!(ignore_bad_directories {
+#[test]
+fn ignore_bad_directories() {
use std::os::unix::prelude::*;
let foo = project("foo")
.file("Cargo.toml", r#"
execs().with_status(0));
perms.set_mode(0o755);
fs::set_permissions(&dir, perms).unwrap();
-});
+}
-test!(bad_cargo_config {
+#[test]
+fn bad_cargo_config() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
[..].cargo[..]config:2:20-2:21 expected `=`, but found `i`
"));
-});
+}
-test!(cargo_platform_specific_dependency {
+#[test]
+fn cargo_platform_specific_dependency() {
let host = ::rustc_host();
let p = project("foo")
.file("Cargo.toml", &format!(r#"
assert_that(&p.bin("foo"), existing_file());
assert_that(p.cargo("test"),
execs().with_status(0));
-});
+}
-test!(bad_platform_specific_dependency {
+#[test]
+fn bad_platform_specific_dependency() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build"),
execs().with_status(101));
-});
+}
-test!(cargo_platform_specific_dependency_wrong_platform {
+#[test]
+fn cargo_platform_specific_dependency_wrong_platform() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
let mut lockfile = String::new();
File::open(&loc).unwrap().read_to_string(&mut lockfile).unwrap();
assert!(lockfile.contains("bar"))
-});
+}
-test!(example_bin_same_name {
+#[test]
+fn example_bin_same_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.bin("foo"), is_not(existing_file()));
assert_that(&p.bin("examples/foo"), existing_file());
-});
+}
-test!(compile_then_delete {
+#[test]
+fn compile_then_delete() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
fs::remove_file(&p.bin("foo")).unwrap();
assert_that(p.cargo("run"),
execs().with_status(0));
-});
+}
-test!(transitive_dependencies_not_available {
+#[test]
+fn transitive_dependencies_not_available() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
.with_stderr_contains("\
[..] can't find crate for `bbbbb`[..]
"));
-});
+}
-test!(cyclic_deps_rejected {
+#[test]
+fn cyclic_deps_rejected() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
.with_stderr("\
[ERROR] cyclic package dependency: package `foo v0.0.1 ([..])` depends on itself
"));
-});
+}
-test!(predictable_filenames {
+#[test]
+fn predictable_filenames() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
env::consts::DLL_SUFFIX);
assert_that(&p.root().join("target/debug").join(dylib_name),
existing_file());
-});
+}
-test!(dashes_to_underscores {
+#[test]
+fn dashes_to_underscores() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
assert_that(&p.bin("foo-bar"), existing_file());
-});
+}
-test!(dashes_in_crate_name_bad {
+#[test]
+fn dashes_in_crate_name_bad() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(101));
-});
+}
-test!(rustc_env_var {
+#[test]
+fn rustc_env_var() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[..]
"));
assert_that(&p.bin("a"), is_not(existing_file()));
-});
+}
-test!(filtering {
+#[test]
+fn filtering() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.bin("b"), is_not(existing_file()));
assert_that(&p.bin("examples/a"), existing_file());
assert_that(&p.bin("examples/b"), is_not(existing_file()));
-});
+}
-test!(ignore_dotfile {
+#[test]
+fn ignore_dotfile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(ignore_dotdirs {
+#[test]
+fn ignore_dotdirs() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(dotdir_root {
+#[test]
+fn dotdir_root() {
let p = ProjectBuilder::new("foo", root().join(".foo"))
.file("Cargo.toml", r#"
[package]
p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(custom_target_dir {
+#[test]
+fn custom_target_dir() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
existing_file());
assert_that(&p.root().join("target/debug").join(&exe_name),
existing_file());
-});
+}
-test!(rustc_no_trans {
+#[test]
+fn rustc_no_trans() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("rustc").arg("-v").arg("--").arg("-Zno-trans"),
execs().with_status(0));
-});
+}
-test!(build_multiple_packages {
+#[test]
+fn build_multiple_packages() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(d2_path, existing_file());
assert_that(process(d2_path),
execs().with_stdout("d2"));
-});
+}
-test!(invalid_spec {
+#[test]
+fn invalid_spec() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101).with_stderr("\
[ERROR] package id specification `notAValidDep` matched no packages
"));
-});
+}
-test!(manifest_with_bom_is_ok {
+#[test]
+fn manifest_with_bom_is_ok() {
let p = project("foo")
.file("Cargo.toml", "\u{FEFF}
[package]
.file("src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(panic_abort_compiles_with_panic_abort {
+#[test]
+fn panic_abort_compiles_with_panic_abort() {
if !::is_nightly() {
return
}
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0)
.with_stderr_contains("[..] -C panic=abort [..]"));
-});
+}
use support::paths::CargoPathExt;
use hamcrest::{assert_that, existing_file, existing_dir};
-fn setup() {
-}
-
-test!(custom_build_script_failed {
+#[test]
+fn custom_build_script_failed() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Process didn't exit successfully: `[..]build[..]build-script-build[..]` \
(exit code: 101)",
url = p.url())));
-});
+}
-test!(custom_build_env_vars {
+#[test]
+fn custom_build_env_vars() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build").arg("--features").arg("bar_feat"),
execs().with_status(0));
-});
+}
-test!(custom_build_script_wrong_rustc_flags {
+#[test]
+fn custom_build_script_wrong_rustc_flags() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] Only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ({})`: \
`-aaa -bbb`",
p.url())));
-});
+}
/*
-test!(custom_build_script_rustc_flags {
+#[test]
+fn custom_build_script_rustc_flags() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
dir = p.root().display(),
url = p.url(),
)));
-});
+}
*/
-test!(links_no_build_cmd {
+#[test]
+fn links_no_build_cmd() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] package `foo v0.5.0 (file://[..])` specifies that it links to `a` but does \
not have a custom build script
"));
-});
+}
-test!(links_duplicates {
+#[test]
+fn links_duplicates() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[..] v0.5.0 (file://[..])
[..] v0.5.0 (file://[..])
"));
-});
+}
-test!(overrides_and_links {
+#[test]
+fn overrides_and_links() {
let target = ::rustc_host();
let p = project("foo")
[..]
[RUNNING] `rustc [..] --crate-name foo [..] -L foo -L bar[..]`
"));
-});
+}
-test!(unused_overrides {
+#[test]
+fn unused_overrides() {
let target = ::rustc_host();
let p = project("foo")
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(links_passes_env_vars {
+#[test]
+fn links_passes_env_vars() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(only_rerun_build_script {
+#[test]
+fn only_rerun_build_script() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[RUNNING] `[..]build-script-build[..]`
[RUNNING] `rustc [..] --crate-name foo [..]`
"));
-});
+}
-test!(rebuild_continues_to_pass_env_vars {
+#[test]
+fn rebuild_continues_to_pass_env_vars() {
let a = project("a")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(testing_and_such {
+#[test]
+fn testing_and_such() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.5.0 (file://[..])
[RUNNING] `target[..]foo[..]`
"));
-});
+}
-test!(propagation_of_l_flags {
+#[test]
+fn propagation_of_l_flags() {
let target = ::rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
[COMPILING] foo v0.5.0 (file://[..])
[RUNNING] `rustc [..] --crate-name foo [..] -L bar -L foo`
"));
-});
+}
-test!(propagation_of_l_flags_new {
+#[test]
+fn propagation_of_l_flags_new() {
let target = ::rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
[COMPILING] foo v0.5.0 (file://[..])
[RUNNING] `rustc [..] --crate-name foo [..] -L bar -L foo`
"));
-});
+}
-test!(build_deps_simple {
+#[test]
+fn build_deps_simple() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[RUNNING] `[..]foo-[..]build-script-build[..]`
[RUNNING] `rustc [..] --crate-name foo [..]`
"));
-});
+}
-test!(build_deps_not_for_normal {
+#[test]
+fn build_deps_not_for_normal() {
let target = ::rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
Caused by:
Process didn't exit successfully: [..]
"));
-});
+}
-test!(build_cmd_with_a_build_cmd {
+#[test]
+fn build_cmd_with_a_build_cmd() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
--out-dir [..]target[..]debug --emit=dep-info,link \
-L [..]target[..]debug -L [..]target[..]deps`
"));
-});
+}
-test!(out_dir_is_preserved {
+#[test]
+fn out_dir_is_preserved() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
File::create(&p.root().join("foo")).unwrap();
assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(output_separate_lines {
+#[test]
+fn output_separate_lines() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] could not find native static library [..]
[ERROR] Could not compile [..]
"));
-});
+}
-test!(output_separate_lines_new {
+#[test]
+fn output_separate_lines_new() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] could not find native static library [..]
[ERROR] Could not compile [..]
"));
-});
+}
#[cfg(not(windows))] // FIXME(#867)
-test!(code_generation {
+#[test]
+fn code_generation() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("test"),
execs().with_status(0));
-});
+}
-test!(release_with_build_script {
+#[test]
+fn release_with_build_script() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0));
-});
+}
-test!(build_script_only {
+#[test]
+fn build_script_only() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present"));
-});
+}
-test!(shared_dep_with_a_build_script {
+#[test]
+fn shared_dep_with_a_build_script() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(transitive_dep_host {
+#[test]
+fn transitive_dep_host() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build"),
execs().with_status(0));
-});
+}
-test!(test_a_lib_with_a_build_command {
+#[test]
+fn test_a_lib_with_a_build_command() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#);
assert_that(p.cargo_process("test"),
execs().with_status(0));
-});
+}
-test!(test_dev_dep_build_script {
+#[test]
+fn test_dev_dep_build_script() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.file("a/src/lib.rs", "");
assert_that(p.cargo_process("test"), execs().with_status(0));
-});
+}
-test!(build_script_with_dynamic_native_dependency {
+#[test]
+fn build_script_with_dynamic_native_dependency() {
let build = project("builder")
.file("Cargo.toml", r#"
[package]
assert_that(foo.cargo_process("build").env("SRC", build.root()),
execs().with_status(0));
-});
+}
-test!(profile_and_opt_level_set_correctly {
+#[test]
+fn profile_and_opt_level_set_correctly() {
let build = project("builder")
.file("Cargo.toml", r#"
[package]
"#);
assert_that(build.cargo_process("bench"),
execs().with_status(0));
-});
+}
-test!(build_script_with_lto {
+#[test]
+fn build_script_with_lto() {
let build = project("builder")
.file("Cargo.toml", r#"
[package]
"#);
assert_that(build.cargo_process("build"),
execs().with_status(0));
-});
+}
-test!(test_duplicate_deps {
+#[test]
+fn test_duplicate_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.file("bar/src/lib.rs", "pub fn do_nothing() {}");
assert_that(p.cargo_process("build"), execs().with_status(0));
-});
+}
-test!(cfg_feedback {
+#[test]
+fn cfg_feedback() {
let build = project("builder")
.file("Cargo.toml", r#"
[package]
"#);
assert_that(build.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(cfg_override {
+#[test]
+fn cfg_override() {
let target = ::rustc_host();
let p = project("foo")
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(cfg_test {
+#[test]
+fn cfg_test() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(cfg_doc {
+#[test]
+fn cfg_doc() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file());
-});
+}
-test!(cfg_override_test {
+#[test]
+fn cfg_override_test() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(cfg_override_doc {
+#[test]
+fn cfg_override_doc() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file());
-});
+}
-test!(flags_go_into_tests {
+#[test]
+fn flags_go_into_tests() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(diamond_passes_args_only_once {
+#[test]
+fn diamond_passes_args_only_once() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.5.0 ([..]
[RUNNING] `[..]rlib -L native=test`
"));
-});
+}
-test!(adding_an_override_invalidates {
+#[test]
+fn adding_an_override_invalidates() {
let target = ::rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
[COMPILING] foo v0.5.0 ([..]
[RUNNING] `rustc [..] -L native=bar`
"));
-});
+}
-test!(changing_an_override_invalidates {
+#[test]
+fn changing_an_override_invalidates() {
let target = ::rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
[COMPILING] foo v0.5.0 ([..]
[RUNNING] `rustc [..] -L native=bar`
"));
-});
+}
-test!(rebuild_only_on_explicit_paths {
+#[test]
+fn rebuild_only_on_explicit_paths() {
let p = project("a")
.file("Cargo.toml", r#"
[project]
[RUNNING] `[..]build-script-build[..]`
[RUNNING] `rustc src[..]lib.rs [..]`
"));
-});
+}
-test!(doctest_recieves_build_link_args {
+#[test]
+fn doctest_recieves_build_link_args() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stderr_contains("\
[RUNNING] `rustdoc --test [..] --crate-name foo [..]-L native=bar[..]`
"));
-});
+}
-test!(please_respect_the_dag {
+#[test]
+fn please_respect_the_dag() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stderr_contains("\
[RUNNING] `rustc [..] -L native=foo -L native=bar[..]`
"));
-});
+}
-test!(non_utf8_output {
+#[test]
+fn non_utf8_output() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(custom_target_dir {
+#[test]
+fn custom_target_dir() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(panic_abort_with_build_scripts {
+#[test]
+fn panic_abort_with_build_scripts() {
if !::is_nightly() {
return
}
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0));
-});
+}
use hamcrest::{assert_that,existing_file};
use cargo::util::process;
-fn setup() {
-}
-
-test!(cargo_compile_simple_git_dep {
+#[test]
+fn cargo_compile_simple_git_dep() {
let project = project("foo");
let git_project = git::new("dep1", |project| {
project
assert_that(
process(&project.bin("foo")),
execs().with_stdout("hello world\n"));
-});
+}
-test!(cargo_compile_git_dep_branch {
+#[test]
+fn cargo_compile_git_dep_branch() {
let project = project("foo");
let git_project = git::new("dep1", |project| {
project
assert_that(
process(&project.bin("foo")),
execs().with_stdout("hello world\n"));
-});
+}
-test!(cargo_compile_git_dep_tag {
+#[test]
+fn cargo_compile_git_dep_tag() {
let project = project("foo");
let git_project = git::new("dep1", |project| {
project
assert_that(project.cargo("build"),
execs().with_status(0));
-});
+}
-test!(cargo_compile_with_nested_paths {
+#[test]
+fn cargo_compile_with_nested_paths() {
let git_project = git::new("dep1", |project| {
project
.file("Cargo.toml", r#"
assert_that(process(&p.bin("parent")),
execs().with_stdout("hello world\n"));
-});
+}
-test!(cargo_compile_with_meta_package {
+#[test]
+fn cargo_compile_with_meta_package() {
let git_project = git::new("meta-dep", |project| {
project
.file("dep1/Cargo.toml", r#"
assert_that(process(&p.bin("parent")),
execs().with_stdout("this is dep1 this is dep2\n"));
-});
+}
-test!(cargo_compile_with_short_ssh_git {
+#[test]
+fn cargo_compile_with_short_ssh_git() {
let url = "git@github.com:a/dep";
let project = project("project")
Caused by:
invalid url `{}`: relative URL without a base
", url)));
-});
+}
-test!(two_revs_same_deps {
+#[test]
+fn two_revs_same_deps() {
let bar = git::new("meta-dep", |project| {
project.file("Cargo.toml", r#"
[package]
execs().with_status(0));
assert_that(&foo.bin("foo"), existing_file());
assert_that(foo.process(&foo.bin("foo")), execs().with_status(0));
-});
+}
-test!(recompilation {
+#[test]
+fn recompilation() {
let git_project = git::new("bar", |project| {
project
.file("Cargo.toml", r#"
assert_that(p.cargo("build"),
execs().with_stderr(&format!("[COMPILING] foo v0.5.0 ({})\n",
p.url())));
-});
+}
-test!(update_with_shared_deps {
+#[test]
+fn update_with_shared_deps() {
let git_project = git::new("bar", |project| {
project
.file("Cargo.toml", r#"
assert_that(p.cargo("update").arg("-p").arg("bar"),
execs().with_stderr(&format!("[UPDATING] git repository `{}`",
git_project.url())));
-});
+}
-test!(dep_with_submodule {
+#[test]
+fn dep_with_submodule() {
let project = project("foo");
let git_project = git::new("dep1", |project| {
project
[UPDATING] git repository [..]
[COMPILING] dep1 [..]
[COMPILING] foo [..]").with_status(0));
-});
+}
-test!(two_deps_only_update_one {
+#[test]
+fn two_deps_only_update_one() {
let project = project("foo");
let git1 = git::new("dep1", |project| {
project
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
[UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\
", git1.url())));
-});
+}
-test!(stale_cached_version {
+#[test]
+fn stale_cached_version() {
let bar = git::new("meta-dep", |project| {
project.file("Cargo.toml", r#"
[package]
[COMPILING] foo v0.0.0 ({foo})
", bar = bar.url(), foo = foo.url())));
assert_that(foo.process(&foo.bin("foo")), execs().with_status(0));
-});
+}
-test!(dep_with_changed_submodule {
+#[test]
+fn dep_with_changed_submodule() {
let project = project("foo");
let git_project = git::new("dep1", |project| {
project
[RUNNING] `target[..]foo[..]`\n")
.with_stdout("project3\n")
.with_status(0));
-});
+}
-test!(dev_deps_with_testing {
+#[test]
+fn dev_deps_with_testing() {
let p2 = git::new("bar", |project| {
project.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(git_build_cmd_freshness {
+#[test]
+fn git_build_cmd_freshness() {
let foo = git::new("foo", |project| {
project.file("Cargo.toml", r#"
[package]
assert_that(foo.cargo("build"),
execs().with_status(0)
.with_stdout(""));
-});
+}
-test!(git_name_not_always_needed {
+#[test]
+fn git_name_not_always_needed() {
let p2 = git::new("bar", |project| {
project.file("Cargo.toml", r#"
[package]
[UPDATING] git repository `{bar}`
[COMPILING] foo v0.5.0 ({url})
", url = p.url(), bar = p2.url())));
-});
+}
-test!(git_repo_changing_no_rebuild {
+#[test]
+fn git_repo_changing_no_rebuild() {
let bar = git::new("bar", |project| {
project.file("Cargo.toml", r#"
[package]
// even though the git repo has changed.
assert_that(p1.cargo("build"),
execs().with_stdout(""));
-});
+}
-test!(git_dep_build_cmd {
+#[test]
+fn git_dep_build_cmd() {
let p = git::new("foo", |project| {
project.file("Cargo.toml", r#"
[project]
assert_that(process(&p.bin("foo")),
execs().with_stdout("1\n"));
-});
+}
-test!(fetch_downloads {
+#[test]
+fn fetch_downloads() {
let bar = git::new("bar", |project| {
project.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("fetch"),
execs().with_status(0).with_stdout(""));
-});
+}
-test!(warnings_in_git_dep {
+#[test]
+fn warnings_in_git_dep() {
let bar = git::new("bar", |project| {
project.file("Cargo.toml", r#"
[package]
bar.url(),
bar.url(),
p.url())));
-});
+}
-test!(update_ambiguous {
+#[test]
+fn update_ambiguous() {
let foo1 = git::new("foo1", |project| {
project.file("Cargo.toml", r#"
[package]
foo:0.[..].0
foo:0.[..].0
"));
-});
+}
-test!(update_one_dep_in_repo_with_many_deps {
+#[test]
+fn update_one_dep_in_repo_with_many_deps() {
let foo = git::new("foo", |project| {
project.file("Cargo.toml", r#"
[package]
.with_stderr(&format!("\
[UPDATING] git repository `{}`
", foo.url())));
-});
+}
-test!(switch_deps_does_not_update_transitive {
+#[test]
+fn switch_deps_does_not_update_transitive() {
let transitive = git::new("transitive", |project| {
project.file("Cargo.toml", r#"
[package]
[COMPILING] dep [..]
[COMPILING] project [..]
", dep2.url())));
-});
+}
-test!(update_one_source_updates_all_packages_in_that_git_source {
+#[test]
+fn update_one_source_updates_all_packages_in_that_git_source() {
let dep = git::new("dep", |project| {
project.file("Cargo.toml", r#"
[package]
.read_to_string(&mut lockfile).unwrap();
assert!(!lockfile.contains(&rev1.to_string()),
"{} in {}", rev1, lockfile);
-});
+}
-test!(switch_sources {
+#[test]
+fn switch_sources() {
let a1 = git::new("a1", |project| {
project.file("Cargo.toml", r#"
[package]
[COMPILING] b v0.5.0 ([..])
[COMPILING] project v0.5.0 ([..])
"));
-});
+}
-test!(dont_require_submodules_are_checked_out {
+#[test]
+fn dont_require_submodules_are_checked_out() {
let project = project("foo");
let git1 = git::new("dep1", |p| {
p.file("Cargo.toml", r#"
assert_that(git1.cargo("build").arg("-v").cwd(&dst),
execs().with_status(0));
-});
+}
-test!(doctest_same_name {
+#[test]
+fn doctest_same_name() {
let a2 = git::new("a2", |p| {
p.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
-});
+}
-test!(lints_are_suppressed {
+#[test]
+fn lints_are_suppressed() {
let a = git::new("a", |p| {
p.file("Cargo.toml", r#"
[project]
[COMPILING] a v0.5.0 ([..])
[COMPILING] foo v0.0.1 ([..])
"));
-});
+}
-test!(denied_lints_are_allowed {
+#[test]
+fn denied_lints_are_allowed() {
let enabled = super::RUSTC.with(|r| r.cap_lints);
if !enabled { return }
[COMPILING] a v0.5.0 ([..])
[COMPILING] foo v0.0.1 ([..])
"));
-});
+}
-test!(add_a_git_dep {
+#[test]
+fn add_a_git_dep() {
let git = git::new("git", |p| {
p.file("Cargo.toml", r#"
[project]
"#, git.url()).as_bytes()).unwrap();
assert_that(p.cargo("build"), execs().with_status(0));
-});
+}
use hamcrest::{assert_that, existing_file};
use cargo::util::process;
-fn setup() {
-}
-
-test!(cargo_compile_with_nested_deps_shorthand {
+#[test]
+fn cargo_compile_with_nested_deps_shorthand() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.5.0 ({})\n",
p.url(),
p.url())));
-});
+}
-test!(cargo_compile_with_root_dev_deps {
+#[test]
+fn cargo_compile_with_root_dev_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
p2.build();
assert_that(p.cargo_process("build"),
execs().with_status(101))
-});
+}
-test!(cargo_compile_with_root_dev_deps_with_testing {
+#[test]
+fn cargo_compile_with_root_dev_deps_with_testing() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(cargo_compile_with_transitive_dev_deps {
+#[test]
+fn cargo_compile_with_transitive_dev_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(process(&p.bin("foo")),
execs().with_stdout("zoidberg\n"));
-});
+}
-test!(no_rebuild_dependency {
+#[test]
+fn no_rebuild_dependency() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
[COMPILING] foo v0.5.0 ({})\n",
p.url(),
p.url())));
-});
+}
-test!(deep_dependencies_trigger_rebuild {
+#[test]
+fn deep_dependencies_trigger_rebuild() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
p.url(),
p.url())));
-});
+}
-test!(no_rebuild_two_deps {
+#[test]
+fn no_rebuild_two_deps() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
assert_that(p.cargo("build"),
execs().with_stdout(""));
assert_that(&p.bin("foo"), existing_file());
-});
+}
-test!(nested_deps_recompile {
+#[test]
+fn nested_deps_recompile() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo("build"),
execs().with_stderr(&format!("[COMPILING] foo v0.5.0 ({})\n",
p.url())));
-});
+}
-test!(error_message_for_missing_manifest {
+#[test]
+fn error_message_for_missing_manifest() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[..] (os error [..])
"));
-});
+}
-test!(override_relative {
+#[test]
+fn override_relative() {
let bar = project("bar")
.file("Cargo.toml", r#"
[package]
bar.build();
assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
-});
+}
-test!(override_self {
+#[test]
+fn override_self() {
let bar = project("bar")
.file("Cargo.toml", r#"
[package]
bar.build();
assert_that(p.cargo_process("build"), execs().with_status(0));
-});
+}
-test!(override_path_dep {
+#[test]
+fn override_path_dep() {
let bar = project("bar")
.file("p1/Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-});
+}
-test!(path_dep_build_cmd {
+#[test]
+fn path_dep_build_cmd() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(process(&p.bin("foo")),
execs().with_stdout("1\n"));
-});
+}
-test!(dev_deps_no_rebuild_lib {
+#[test]
+fn dev_deps_no_rebuild_lib() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(custom_target_no_rebuild {
+#[test]
+fn custom_target_no_rebuild() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stderr("\
[COMPILING] b v0.5.0 ([..])
"));
-});
+}
-test!(override_and_depend {
+#[test]
+fn override_and_depend() {
let p = project("foo")
.file("a/a1/Cargo.toml", r#"
[project]
[COMPILING] a1 v0.5.0 ([..])
[COMPILING] b v0.5.0 ([..])
"));
-});
+}
-test!(missing_path_dependency {
+#[test]
+fn missing_path_dependency() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
[..] (os error [..])
"));
-});
+}
use support::{project, execs};
use hamcrest::assert_that;
-fn setup() {
-}
-
-test!(plugin_to_the_max {
+#[test]
+fn plugin_to_the_max() {
if !::is_nightly() { return }
let foo = project("foo")
execs().with_status(0));
assert_that(foo.cargo("doc"),
execs().with_status(0));
-});
+}
-test!(plugin_with_dynamic_native_dependency {
+#[test]
+fn plugin_with_dynamic_native_dependency() {
if !::is_nightly() { return }
let build = project("builder")
assert_that(foo.cargo_process("build").env("SRC", &lib).arg("-v"),
execs().with_status(0));
-});
+}
-test!(plugin_integration {
+#[test]
+fn plugin_integration() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
-});
+}
-test!(doctest_a_plugin {
+#[test]
+fn doctest_a_plugin() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
-});
+}
// See #1515
-test!(native_plugin_dependency_with_custom_ar_linker {
+#[test]
+fn native_plugin_dependency_with_custom_ar_linker() {
let target = ::rustc_host();
let foo = project("foo")
[RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]`
[ERROR] could not exec the linker [..]
"));
-});
+}
use support::{project, execs, paths};
use hamcrest::assert_that;
-fn setup() {
-}
-
-test!(env_rustflags_normal_source {
+#[test]
+fn env_rustflags_normal_source() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101));
assert_that(p.cargo("bench").env("RUSTFLAGS", "-Z bogus"),
execs().with_status(101));
-});
+}
-test!(env_rustflags_build_script {
+#[test]
+fn env_rustflags_build_script() {
// RUSTFLAGS should be passed to rustc for build scripts
// when --target is not specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
-});
+}
-test!(env_rustflags_build_script_dep {
+#[test]
+fn env_rustflags_build_script_dep() {
// RUSTFLAGS should be passed to rustc for build scripts
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
-});
+}
-test!(env_rustflags_plugin {
+#[test]
+fn env_rustflags_plugin() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
-});
+}
-test!(env_rustflags_plugin_dep {
+#[test]
+fn env_rustflags_plugin_dep() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
-});
+}
-test!(env_rustflags_normal_source_with_target {
+#[test]
+fn env_rustflags_normal_source_with_target() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("bench").env("RUSTFLAGS", "-Z bogus")
.arg("--target").arg(host),
execs().with_status(101));
-});
+}
-test!(env_rustflags_build_script_with_target {
+#[test]
+fn env_rustflags_build_script_with_target() {
// RUSTFLAGS should not be passed to rustc for build scripts
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(env_rustflags_build_script_dep_with_target {
+#[test]
+fn env_rustflags_build_script_dep_with_target() {
// RUSTFLAGS should not be passed to rustc for build scripts
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(env_rustflags_plugin_with_target {
+#[test]
+fn env_rustflags_plugin_with_target() {
// RUSTFLAGS should not be passed to rustc for plugins
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(env_rustflags_plugin_dep_with_target {
+#[test]
+fn env_rustflags_plugin_dep_with_target() {
// RUSTFLAGS should not be passed to rustc for plugins
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(env_rustflags_recompile {
+#[test]
+fn env_rustflags_recompile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
// Setting RUSTFLAGS forces a recompile
assert_that(p.cargo("build").env("RUSTFLAGS", "-Z bogus"),
execs().with_status(101));
-});
+}
-test!(env_rustflags_recompile2 {
+#[test]
+fn env_rustflags_recompile2() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
// Setting RUSTFLAGS forces a recompile
assert_that(p.cargo("build").env("RUSTFLAGS", "-Z bogus"),
execs().with_status(101));
-});
+}
-test!(env_rustflags_no_recompile {
+#[test]
+fn env_rustflags_no_recompile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(0));
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_stdout("").with_status(0));
-});
+}
-test!(build_rustflags_normal_source {
+#[test]
+fn build_rustflags_normal_source() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101));
assert_that(p.cargo("bench"),
execs().with_status(101));
-});
+}
-test!(build_rustflags_build_script {
+#[test]
+fn build_rustflags_build_script() {
// RUSTFLAGS should be passed to rustc for build scripts
// when --target is not specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(build_rustflags_build_script_dep {
+#[test]
+fn build_rustflags_build_script_dep() {
// RUSTFLAGS should be passed to rustc for build scripts
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
assert_that(foo.cargo("build"),
execs().with_status(0));
-});
+}
-test!(build_rustflags_plugin {
+#[test]
+fn build_rustflags_plugin() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(build_rustflags_plugin_dep {
+#[test]
+fn build_rustflags_plugin_dep() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
assert_that(foo.cargo("build"),
execs().with_status(0));
-});
+}
-test!(build_rustflags_normal_source_with_target {
+#[test]
+fn build_rustflags_normal_source_with_target() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("bench")
.arg("--target").arg(host),
execs().with_status(101));
-});
+}
-test!(build_rustflags_build_script_with_target {
+#[test]
+fn build_rustflags_build_script_with_target() {
// RUSTFLAGS should not be passed to rustc for build scripts
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(p.cargo("build")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(build_rustflags_build_script_dep_with_target {
+#[test]
+fn build_rustflags_build_script_dep_with_target() {
// RUSTFLAGS should not be passed to rustc for build scripts
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(foo.cargo("build")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(build_rustflags_plugin_with_target {
+#[test]
+fn build_rustflags_plugin_with_target() {
// RUSTFLAGS should not be passed to rustc for plugins
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(p.cargo("build")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(build_rustflags_plugin_dep_with_target {
+#[test]
+fn build_rustflags_plugin_dep_with_target() {
// RUSTFLAGS should not be passed to rustc for plugins
// when --target is specified.
// In this test if --cfg foo is passed the build will fail.
assert_that(foo.cargo("build")
.arg("--target").arg(host),
execs().with_status(0));
-});
+}
-test!(build_rustflags_recompile {
+#[test]
+fn build_rustflags_recompile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("build"),
execs().with_status(101));
-});
+}
-test!(build_rustflags_recompile2 {
+#[test]
+fn build_rustflags_recompile2() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("build"),
execs().with_status(101));
-});
+}
-test!(build_rustflags_no_recompile {
+#[test]
+fn build_rustflags_no_recompile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(0));
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_stdout("").with_status(0));
-});
+}
use support::registry::Package;
use test_cargo_install::{cargo_home, has_installed_exe};
-fn setup() {}
-
fn pkg(name: &str, vers: &str) {
Package::new(name, vers)
.file("src/main.rs", "fn main() {{}}")
.publish();
}
-test!(multiple_installs {
+#[test]
+fn multiple_installs() {
let p = project("foo")
.file("a/Cargo.toml", r#"
[package]
assert_that(cargo_home(), has_installed_exe("foo"));
assert_that(cargo_home(), has_installed_exe("bar"));
-});
+}
-test!(concurrent_installs {
+#[test]
+fn concurrent_installs() {
const LOCKED_BUILD: &'static str = "waiting for file lock on build directory";
pkg("foo", "0.0.1");
assert_that(cargo_home(), has_installed_exe("foo"));
assert_that(cargo_home(), has_installed_exe("bar"));
-});
+}
-test!(one_install_should_be_bad {
+#[test]
+fn one_install_should_be_bad() {
let p = project("foo")
.file("a/Cargo.toml", r#"
[package]
"));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(multiple_registry_fetches {
+#[test]
+fn multiple_registry_fetches() {
let mut pkg = Package::new("bar", "1.0.2");
for i in 0..10 {
let name = format!("foo{}", i);
existing_file());
assert_that(&p.root().join("b/target/debug").join(format!("bar{}", suffix)),
existing_file());
-});
+}
-test!(git_same_repo_different_tags {
+#[test]
+fn git_same_repo_different_tags() {
let a = git::new("dep", |project| {
project.file("Cargo.toml", r#"
[project]
assert_that(a, execs().with_status(0));
assert_that(b, execs().with_status(0));
-});
+}
-test!(git_same_branch_different_revs {
+#[test]
+fn git_same_branch_different_revs() {
let a = git::new("dep", |project| {
project.file("Cargo.toml", r#"
[project]
assert_that(a, execs().with_status(0));
assert_that(b, execs().with_status(0));
-});
+}
-test!(same_project {
+#[test]
+fn same_project() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(a, execs().with_status(0));
assert_that(b, execs().with_status(0));
-});
+}
// Make sure that if Cargo dies while holding a lock that it's released and the
// next Cargo to come in will take over cleanly.
-test!(killing_cargo_releases_the_lock {
+#[test]
+fn killing_cargo_releases_the_lock() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
// We killed `a`, so it shouldn't succeed, but `b` should have succeeded.
assert!(!a.status.success());
assert_that(b, execs().with_status(0));
-});
+}
-test!(debug_release_ok {
+#[test]
+fn debug_release_ok() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(b, execs().with_status(0).with_stderr("\
[COMPILING] foo v0.0.0 [..]
"));
-});
+}
use support::{project, execs};
use hamcrest::assert_that;
-fn setup() {
-}
-
-test!(read_env_vars_for_config {
+#[test]
+fn read_env_vars_for_config() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build").env("CARGO_BUILD_JOBS", "100"),
execs().with_status(0));
-});
+}
use hamcrest::{assert_that, existing_file};
use cargo::util::process;
-fn setup() {
-}
-
fn disabled() -> bool {
// First, disable if ./configure requested so
match env::var("CFG_DISABLE_CROSS_TESTS") {
format!("{}-{}", arch, platform)
}
-test!(simple_cross {
+#[test]
+fn simple_cross() {
if disabled() { return }
let p = project("foo")
assert_that(process(&p.target_bin(&target, "foo")),
execs().with_status(0));
-});
+}
-test!(simple_cross_config {
+#[test]
+fn simple_cross_config() {
if disabled() { return }
let p = project("foo")
assert_that(process(&p.target_bin(&target, "foo")),
execs().with_status(0));
-});
+}
-test!(simple_deps {
+#[test]
+fn simple_deps() {
if disabled() { return }
let p = project("foo")
assert_that(process(&p.target_bin(&target, "foo")),
execs().with_status(0));
-});
+}
-test!(plugin_deps {
+#[test]
+fn plugin_deps() {
if disabled() { return }
if !::is_nightly() { return }
assert_that(process(&foo.target_bin(&target, "foo")),
execs().with_status(0));
-});
+}
-test!(plugin_to_the_max {
+#[test]
+fn plugin_to_the_max() {
if disabled() { return }
if !::is_nightly() { return }
assert_that(process(&foo.target_bin(&target, "foo")),
execs().with_status(0));
-});
+}
-test!(linker_and_ar {
+#[test]
+fn linker_and_ar() {
if disabled() { return }
let target = alternate();
url = p.url(),
target = target,
)));
-});
+}
-test!(plugin_with_extra_dylib_dep {
+#[test]
+fn plugin_with_extra_dylib_dep() {
if disabled() { return }
if !::is_nightly() { return }
let target = alternate();
assert_that(foo.cargo_process("build").arg("--target").arg(&target),
execs().with_status(0));
-});
+}
-test!(cross_tests {
+#[test]
+fn cross_tests() {
if disabled() { return }
let p = project("foo")
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(no_cross_doctests {
+#[test]
+fn no_cross_doctests() {
if disabled() { return }
let p = project("foo")
[COMPILING] foo v0.0.0 ({foo})
[RUNNING] target[..]{triple}[..]foo-[..]
", foo = p.url(), triple = target)));
-});
+}
-test!(simple_cargo_run {
+#[test]
+fn simple_cargo_run() {
if disabled() { return }
let p = project("foo")
let target = alternate();
assert_that(p.cargo_process("run").arg("--target").arg(&target),
execs().with_status(0));
-});
+}
-test!(cross_with_a_build_script {
+#[test]
+fn cross_with_a_build_script() {
if disabled() { return }
let target = alternate();
[RUNNING] `rustc src[..]main.rs [..] --target {target} [..]`
", target = target,
dir = p.root().display())));
-});
+}
-test!(build_script_needed_for_host_and_target {
+#[test]
+fn build_script_needed_for_host_and_target() {
if disabled() { return }
let target = alternate();
.with_stderr_contains(&format!("\
[RUNNING] `rustc src[..]main.rs [..] --target {target} [..] \
-L /path/to/{target}`", target = target)));
-});
+}
-test!(build_deps_for_the_right_arch {
+#[test]
+fn build_deps_for_the_right_arch() {
if disabled() { return }
let p = project("foo")
let target = alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
-});
+}
-test!(build_script_only_host {
+#[test]
+fn build_script_only_host() {
if disabled() { return }
let p = project("foo")
let target = alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
-});
+}
-test!(plugin_build_script_right_arch {
+#[test]
+fn plugin_build_script_right_arch() {
if disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
[RUNNING] `[..]build-script-build[..]`
[RUNNING] `rustc src[..]lib.rs [..]`
"));
-});
+}
-test!(build_script_with_platform_specific_dependencies {
+#[test]
+fn build_script_with_platform_specific_dependencies() {
if disabled() { return }
let target = alternate();
[RUNNING] `{dir}[..]target[..]build[..]foo-[..]build-script-build`
[RUNNING] `rustc src[..]lib.rs [..] --target {target} [..]`
", dir = p.root().display(), target = target)));
-});
+}
-test!(platform_specific_dependencies_do_not_leak {
+#[test]
+fn platform_specific_dependencies_do_not_leak() {
if disabled() { return }
let target = alternate();
execs().with_status(101)
.with_stderr_contains("\
[..] error: can't find crate for `d2`[..]"));
-});
+}
-test!(platform_specific_variables_reflected_in_build_scripts {
+#[test]
+fn platform_specific_variables_reflected_in_build_scripts() {
if disabled() { return }
let target = alternate();
assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target),
execs().with_status(0));
-});
+}
use support::project;
-fn setup() {}
-
#[cfg(unix)]
fn enabled() -> bool {
true
}
}
-test!(ctrl_c_kills_everyone {
+#[test]
+fn ctrl_c_kills_everyone() {
if !enabled() {
return
}
Ok(n) => assert_eq!(n, 0),
Err(e) => assert_eq!(e.kind(), io::ErrorKind::ConnectionReset),
}
-});
+}
#[cfg(unix)]
fn ctrl_c(child: &mut Child) {
use support::{project, execs, path2url};
use hamcrest::{assert_that, existing_file, existing_dir, is_not};
-fn setup() {
-}
-
-test!(simple {
+#[test]
+fn simple() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
dir = path2url(p.root()))));
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
-});
+}
-test!(doc_no_libs {
+#[test]
+fn doc_no_libs() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("doc"),
execs().with_status(0));
-});
+}
-test!(doc_twice {
+#[test]
+fn doc_twice() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("doc"),
execs().with_status(0).with_stdout(""))
-});
+}
-test!(doc_deps {
+#[test]
+fn doc_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
-});
+}
-test!(doc_no_deps {
+#[test]
+fn doc_no_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/index.html"), is_not(existing_file()));
-});
+}
-test!(doc_only_bin {
+#[test]
+fn doc_only_bin() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
-});
+}
-test!(doc_lib_bin_same_name {
+#[test]
+fn doc_lib_bin_same_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[ERROR] cannot document a package where a library and a binary have the same name. \
Consider renaming one or marking the target as `doc = false`
"));
-});
+}
-test!(doc_dash_p {
+#[test]
+fn doc_dash_p() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[..] b v0.0.1 (file://[..])
[DOCUMENTING] a v0.0.1 (file://[..])
"));
-});
+}
-test!(doc_same_name {
+#[test]
+fn doc_same_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("doc"),
execs().with_status(0));
-});
+}
-test!(doc_target {
+#[test]
+fn doc_target() {
const TARGET: &'static str = "arm-unknown-linux-gnueabihf";
if !::is_nightly() { return }
execs().with_status(0));
assert_that(&p.root().join(&format!("target/{}/doc", TARGET)), existing_dir());
assert_that(&p.root().join(&format!("target/{}/doc/foo/index.html", TARGET)), existing_file());
-});
+}
-test!(target_specific_not_documented {
+#[test]
+fn target_specific_not_documented() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("doc"),
execs().with_status(0));
-});
+}
-test!(output_not_captured {
+#[test]
+fn output_not_captured() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
let stderr = str::from_utf8(&output.stderr).unwrap();
assert!(stderr.contains("☃"), "no snowman\n{}", stderr);
assert!(stderr.contains("unknown start of token"), "no message\n{}", stderr);
-});
+}
-test!(target_specific_documented {
+#[test]
+fn target_specific_documented() {
let p = project("foo")
.file("Cargo.toml", &format!(r#"
[package]
assert_that(p.cargo_process("doc"),
execs().with_status(0));
-});
+}
-test!(no_document_build_deps {
+#[test]
+fn no_document_build_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("doc"),
execs().with_status(0));
-});
+}
-test!(doc_release {
+#[test]
+fn doc_release() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[DOCUMENTING] foo v0.0.1 ([..])
[RUNNING] `rustdoc src[..]lib.rs [..]`
"));
-});
+}
-test!(doc_multiple_deps {
+#[test]
+fn doc_multiple_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
assert_that(&p.root().join("target/doc/baz/index.html"), existing_file());
-});
+}
-test!(features {
+#[test]
+fn features() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file());
-});
+}
-test!(rerun_when_dir_removed {
+#[test]
+fn rerun_when_dir_removed() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("doc"),
execs().with_status(0));
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
-});
+}
-test!(document_only_lib {
+#[test]
+fn document_only_lib() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("doc").arg("--lib"),
execs().with_status(0));
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
-});
+}
use support::paths::CargoPathExt;
use hamcrest::assert_that;
-fn setup() {
-}
-
-test!(invalid1 {
+#[test]
+fn invalid1() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
Feature `bar` includes `baz` which is neither a dependency nor another feature
"));
-});
+}
-test!(invalid2 {
+#[test]
+fn invalid2() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
Features and dependencies cannot have the same name: `bar`
"));
-});
+}
-test!(invalid3 {
+#[test]
+fn invalid3() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Feature `bar` depends on `baz` which is not an optional dependency.
Consider adding `optional = true` to the dependency
"));
-});
+}
-test!(invalid4 {
+#[test]
+fn invalid4() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
execs().with_status(101).with_stderr("\
[ERROR] Package `foo v0.0.1 ([..])` does not have these features: `test`
"));
-});
+}
-test!(invalid5 {
+#[test]
+fn invalid5() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
Dev-dependencies are not allowed to be optional: `bar`
"));
-});
+}
-test!(invalid6 {
+#[test]
+fn invalid6() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
Feature `foo` requires `bar` which is not an optional dependency
"));
-});
+}
-test!(invalid7 {
+#[test]
+fn invalid7() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
Feature `foo` requires `bar` which is not an optional dependency
"));
-});
+}
-test!(invalid8 {
+#[test]
+fn invalid8() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
execs().with_status(101).with_stderr("\
[ERROR] features in dependencies cannot enable features in other dependencies: `foo/bar`
"));
-});
+}
-test!(no_feature_doesnt_build {
+#[test]
+fn no_feature_doesnt_build() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
", dir = p.url())));
assert_that(p.process(&p.bin("foo")),
execs().with_status(0).with_stdout("bar\n"));
-});
+}
-test!(default_feature_pulled_in {
+#[test]
+fn default_feature_pulled_in() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
", dir = p.url())));
assert_that(p.process(&p.bin("foo")),
execs().with_status(0).with_stdout(""));
-});
+}
-test!(cyclic_feature {
+#[test]
+fn cyclic_feature() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
execs().with_status(101).with_stderr("\
[ERROR] Cyclic feature dependency: feature `default` depends on itself
"));
-});
+}
-test!(cyclic_feature2 {
+#[test]
+fn cyclic_feature2() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
execs().with_status(101).with_stderr("\
[ERROR] Cyclic feature dependency: feature `[..]` depends on itself
"));
-});
+}
-test!(groups_on_groups_on_groups {
+#[test]
+fn groups_on_groups_on_groups() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
[COMPILING] foo v0.0.1 ({dir})
", dir = p.url())));
-});
+}
-test!(many_cli_features {
+#[test]
+fn many_cli_features() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
[COMPILING] foo v0.0.1 ({dir})
", dir = p.url())));
-});
+}
-test!(union_features {
+#[test]
+fn union_features() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] d1 v0.0.1 ({dir}/d1)
[COMPILING] foo v0.0.1 ({dir})
", dir = p.url())));
-});
+}
-test!(many_features_no_rebuilds {
+#[test]
+fn many_features_no_rebuilds() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[FRESH] a v0.1.0 ([..]/a)
[FRESH] b v0.1.0 ([..])
"));
-});
+}
// Tests that all cmd lines work with `--features ""`
-test!(empty_features {
+#[test]
+fn empty_features() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build").arg("--features").arg(""),
execs().with_status(0));
-});
+}
// Tests that all cmd lines work with `--features ""`
-test!(transitive_features {
+#[test]
+fn transitive_features() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("build").arg("--features").arg("foo"),
execs().with_status(0));
-});
+}
-test!(everything_in_the_lockfile {
+#[test]
+fn everything_in_the_lockfile() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert!(lockfile.contains(r#"name = "d1""#), "d1 not found\n{}", lockfile);
assert!(lockfile.contains(r#"name = "d2""#), "d2 not found\n{}", lockfile);
assert!(lockfile.contains(r#"name = "d3""#), "d3 not found\n{}", lockfile);
-});
+}
-test!(no_rebuild_when_frobbing_default_feature {
+#[test]
+fn no_rebuild_when_frobbing_default_feature() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
-});
+}
-test!(unions_work_with_no_default_features {
+#[test]
+fn unions_work_with_no_default_features() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
-});
+}
-test!(optional_and_dev_dep {
+#[test]
+fn optional_and_dev_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(0).with_stderr("\
[COMPILING] test v0.1.0 ([..])
"));
-});
+}
-test!(activating_feature_activates_dep {
+#[test]
+fn activating_feature_activates_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build").arg("--features").arg("a").arg("-v"),
execs().with_status(0));
-});
+}
use support::{project, execs};
use hamcrest::assert_that;
-fn setup() {}
-
-test!(no_deps {
+#[test]
+fn no_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("fetch"),
execs().with_status(0).with_stdout(""));
-});
+}
use support::paths::CargoPathExt;
use hamcrest::{assert_that, existing_file};
-fn setup() {}
-
-test!(modifying_and_moving {
+#[test]
+fn modifying_and_moving() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
fs::rename(&p.root().join("src/a.rs"), &p.root().join("src/b.rs")).unwrap();
assert_that(p.cargo("build"),
execs().with_status(101));
-});
+}
-test!(modify_only_some_files {
+#[test]
+fn modify_only_some_files() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[COMPILING] foo v0.0.1 ({dir})
", dir = path2url(p.root()))));
assert_that(&p.bin("foo"), existing_file());
-});
+}
-test!(rebuild_sub_package_then_while_package {
+#[test]
+fn rebuild_sub_package_then_while_package() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
-test!(changing_features_is_ok {
+#[test]
+fn changing_features_is_ok() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("build"),
execs().with_status(0)
.with_stdout(""));
-});
+}
-test!(rebuild_tests_if_lib_changes {
+#[test]
+fn rebuild_tests_if_lib_changes() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(0));
assert_that(p.cargo("test").arg("-v"),
execs().with_status(101));
-});
+}
-test!(no_rebuild_transitive_target_deps {
+#[test]
+fn no_rebuild_transitive_target_deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[COMPILING] b v0.0.1 ([..])
[COMPILING] foo v0.0.1 ([..])
"));
-});
+}
-test!(rerun_if_changed_in_dep {
+#[test]
+fn rerun_if_changed_in_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(0));
assert_that(p.cargo("build"),
execs().with_status(0).with_stdout(""));
-});
+}
-test!(same_build_dir_cached_packages {
+#[test]
+fn same_build_dir_cached_packages() {
let p = project("foo")
.file("a1/Cargo.toml", r#"
[package]
execs().with_status(0).with_stderr(&format!("\
[COMPILING] a2 v0.0.1 ({dir}/a2)
", dir = p.url())));
-});
+}
use support::{project, execs};
use hamcrest::{assert_that, existing_file, is_not};
-fn setup() {}
-
-test!(adding_and_removing_packages {
+#[test]
+fn adding_and_removing_packages() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
let mut lock4 = String::new();
File::open(&lockfile).unwrap().read_to_string(&mut lock4).unwrap();
assert_eq!(lock1, lock4);
-});
+}
-test!(preserve_metadata {
+#[test]
+fn preserve_metadata() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
let mut lock = String::new();
File::open(&lockfile).unwrap().read_to_string(&mut lock).unwrap();
assert!(lock.contains(metadata.trim()), "{}", lock);
-});
+}
-test!(preserve_line_endings_issue_2076 {
+#[test]
+fn preserve_line_endings_issue_2076() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert!(lock2.starts_with("[root]\r\n"));
assert_eq!(lock1, lock2);
-});
+}
-test!(cargo_update_generate_lockfile {
+#[test]
+fn cargo_update_generate_lockfile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("update"), execs().with_status(0).with_stdout(""));
assert_that(&lockfile, existing_file());
-});
+}
use cargo::util::{process, ProcessBuilder};
-fn setup() {
-}
-
fn cargo_process(s: &str) -> ProcessBuilder {
let mut p = process(&cargo_dir().join("cargo"));
p.arg(s).cwd(&paths::root()).env("HOME", &paths::home());
return p;
}
-test!(simple_lib {
+#[test]
+fn simple_lib() {
assert_that(cargo_process("init").arg("--vcs").arg("none")
.env("USER", "foo"),
execs().with_status(0));
assert_that(cargo_process("build"),
execs().with_status(0));
-});
+}
-test!(simple_bin {
+#[test]
+fn simple_bin() {
let path = paths::root().join("foo");
fs::create_dir(&path).unwrap();
assert_that(cargo_process("init").arg("--bin").arg("--vcs").arg("none")
assert_that(&paths::root().join(&format!("foo/target/debug/foo{}",
env::consts::EXE_SUFFIX)),
existing_file());
-});
+}
fn bin_already_exists(explicit: bool, rellocation: &str) {
let path = paths::root().join("foo");
assert_eq!(Vec::from(content as &[u8]), new_content);
}
-test!(bin_already_exists_explicit {
+#[test]
+fn bin_already_exists_explicit() {
bin_already_exists(true, "src/main.rs")
-});
+}
-test!(bin_already_exists_implicit {
+#[test]
+fn bin_already_exists_implicit() {
bin_already_exists(false, "src/main.rs")
-});
+}
-test!(bin_already_exists_explicit_nosrc {
+#[test]
+fn bin_already_exists_explicit_nosrc() {
bin_already_exists(true, "main.rs")
-});
+}
-test!(bin_already_exists_implicit_nosrc {
+#[test]
+fn bin_already_exists_implicit_nosrc() {
bin_already_exists(false, "main.rs")
-});
+}
-test!(bin_already_exists_implicit_namenosrc {
+#[test]
+fn bin_already_exists_implicit_namenosrc() {
bin_already_exists(false, "foo.rs")
-});
+}
-test!(bin_already_exists_implicit_namesrc {
+#[test]
+fn bin_already_exists_implicit_namesrc() {
bin_already_exists(false, "src/foo.rs")
-});
+}
-test!(confused_by_multiple_lib_files {
+#[test]
+fn confused_by_multiple_lib_files() {
let path = paths::root().join("foo");
fs::create_dir_all(&path.join("src")).unwrap();
"));
assert_that(&paths::root().join("foo/Cargo.toml"), is_not(existing_file()));
-});
+}
-test!(multibin_project_name_clash {
+#[test]
+fn multibin_project_name_clash() {
let path = paths::root().join("foo");
fs::create_dir(&path).unwrap();
"));
assert_that(&paths::root().join("foo/Cargo.toml"), is_not(existing_file()));
-});
+}
fn lib_already_exists(rellocation: &str) {
let path = paths::root().join("foo");
assert_eq!(Vec::from(content as &[u8]), new_content);
}
-test!(lib_already_exists_src {
+#[test]
+fn lib_already_exists_src() {
lib_already_exists("src/lib.rs")
-});
+}
-test!(lib_already_exists_nosrc {
+#[test]
+fn lib_already_exists_nosrc() {
lib_already_exists("lib.rs")
-});
+}
-test!(simple_git {
+#[test]
+fn simple_git() {
assert_that(cargo_process("init").arg("--vcs").arg("git")
.env("USER", "foo"),
execs().with_status(0));
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), existing_dir());
assert_that(&paths::root().join(".gitignore"), existing_file());
-});
+}
-test!(auto_git {
+#[test]
+fn auto_git() {
let td = TempDir::new("cargo").unwrap();
let foo = &td.path().join("foo");
fs::create_dir_all(&foo).unwrap();
assert_that(&foo.join("src/lib.rs"), existing_file());
assert_that(&foo.join(".git"), existing_dir());
assert_that(&foo.join(".gitignore"), existing_file());
-});
+}
-test!(invalid_dir_name {
+#[test]
+fn invalid_dir_name() {
let foo = &paths::root().join("foo.bar");
fs::create_dir_all(&foo).unwrap();
assert_that(cargo_process("init").cwd(foo.clone())
"));
assert_that(&foo.join("Cargo.toml"), is_not(existing_file()));
-});
+}
-test!(reserved_name {
+#[test]
+fn reserved_name() {
let test = &paths::root().join("test");
fs::create_dir_all(&test).unwrap();
assert_that(cargo_process("init").cwd(test.clone())
"));
assert_that(&test.join("Cargo.toml"), is_not(existing_file()));
-});
+}
-test!(git_autodetect {
+#[test]
+fn git_autodetect() {
fs::create_dir(&paths::root().join(".git")).unwrap();
assert_that(cargo_process("init")
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), existing_dir());
assert_that(&paths::root().join(".gitignore"), existing_file());
-});
+}
-test!(mercurial_autodetect {
+#[test]
+fn mercurial_autodetect() {
fs::create_dir(&paths::root().join(".hg")).unwrap();
assert_that(cargo_process("init")
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), is_not(existing_dir()));
assert_that(&paths::root().join(".hgignore"), existing_file());
-});
+}
-test!(gitignore_appended_not_replaced {
+#[test]
+fn gitignore_appended_not_replaced() {
fs::create_dir(&paths::root().join(".git")).unwrap();
File::create(&paths::root().join(".gitignore")).unwrap().write_all(b"qqqqqq\n").unwrap();
let mut contents = String::new();
File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"qqqqqq"#));
-});
+}
-test!(cargo_lock_gitignored_if_lib1 {
+#[test]
+fn cargo_lock_gitignored_if_lib1() {
fs::create_dir(&paths::root().join(".git")).unwrap();
assert_that(cargo_process("init").arg("--vcs").arg("git")
let mut contents = String::new();
File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"Cargo.lock"#));
-});
+}
-test!(cargo_lock_gitignored_if_lib2 {
+#[test]
+fn cargo_lock_gitignored_if_lib2() {
fs::create_dir(&paths::root().join(".git")).unwrap();
File::create(&paths::root().join("lib.rs")).unwrap().write_all(br#""#).unwrap();
let mut contents = String::new();
File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"Cargo.lock"#));
-});
+}
-test!(cargo_lock_not_gitignored_if_bin1 {
+#[test]
+fn cargo_lock_not_gitignored_if_bin1() {
fs::create_dir(&paths::root().join(".git")).unwrap();
assert_that(cargo_process("init").arg("--vcs").arg("git")
let mut contents = String::new();
File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
assert!(!contents.contains(r#"Cargo.lock"#));
-});
+}
-test!(cargo_lock_not_gitignored_if_bin2 {
+#[test]
+fn cargo_lock_not_gitignored_if_bin2() {
fs::create_dir(&paths::root().join(".git")).unwrap();
File::create(&paths::root().join("main.rs")).unwrap().write_all(br#""#).unwrap();
let mut contents = String::new();
File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
assert!(!contents.contains(r#"Cargo.lock"#));
-});
+}
-test!(with_argument {
+#[test]
+fn with_argument() {
assert_that(cargo_process("init").arg("foo").arg("--vcs").arg("none")
.env("USER", "foo"),
execs().with_status(0));
assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
-});
+}
-test!(unknown_flags {
+#[test]
+fn unknown_flags() {
assert_that(cargo_process("init").arg("foo").arg("--flag"),
execs().with_status(1)
.with_stderr("\
cargo init [options] [<path>]
cargo init -h | --help
"));
-});
+}
#[cfg(not(windows))]
-test!(no_filename {
+#[test]
+fn no_filename() {
assert_that(cargo_process("init").arg("/"),
execs().with_status(101)
.with_stderr(&format!("\
[ERROR] cannot auto-detect project name from path \"/\" ; use --name to override
")));
-});
+}
pub use self::InstalledExe as has_installed_exe;
-fn setup() {
-}
-
fn cargo_process(s: &str) -> ProcessBuilder {
let mut p = ::cargo_process();
p.arg(s);
}
}
-test!(simple {
+#[test]
+fn simple() {
pkg("foo", "0.0.1");
assert_that(cargo_process("install").arg("foo"),
",
home = cargo_home().display())));
assert_that(cargo_home(), is_not(has_installed_exe("foo")));
-});
+}
-test!(pick_max_version {
+#[test]
+fn pick_max_version() {
pkg("foo", "0.0.1");
pkg("foo", "0.0.2");
",
home = cargo_home().display())));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(missing {
+#[test]
+fn missing() {
pkg("foo", "0.0.1");
assert_that(cargo_process("install").arg("bar"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] could not find `bar` in `registry file://[..]`
"));
-});
+}
-test!(bad_version {
+#[test]
+fn bad_version() {
pkg("foo", "0.0.1");
assert_that(cargo_process("install").arg("foo").arg("--vers=0.2.0"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] could not find `foo` in `registry file://[..]` with version `0.2.0`
"));
-});
+}
-test!(no_crate {
+#[test]
+fn no_crate() {
assert_that(cargo_process("install"),
execs().with_status(101).with_stderr("\
[ERROR] `[..]` is not a crate root; specify a crate to install [..]
Caused by:
[..] (os error [..])
"));
-});
+}
-test!(install_location_precedence {
+#[test]
+fn install_location_precedence() {
pkg("foo", "0.0.1");
let root = paths::root();
assert_that(cargo_process("install").arg("foo"),
execs().with_status(0));
assert_that(&t4, has_installed_exe("foo"));
-});
+}
-test!(install_path {
+#[test]
+fn install_path() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[ERROR] binary `foo[..]` already exists in destination as part of `foo v0.1.0 [..]`
Add --force to overwrite
"));
-});
+}
-test!(multiple_crates_error {
+#[test]
+fn multiple_crates_error() {
let p = git::repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[package]
[UPDATING] git repository [..]
[ERROR] multiple packages with binaries found: bar, foo
"));
-});
+}
-test!(multiple_crates_select {
+#[test]
+fn multiple_crates_select() {
let p = git::repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[package]
.arg("bar"),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("bar"));
-});
+}
-test!(multiple_crates_auto_binaries {
+#[test]
+fn multiple_crates_auto_binaries() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(multiple_crates_auto_examples {
+#[test]
+fn multiple_crates_auto_examples() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
.arg("--example=foo"),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(no_binaries_or_examples {
+#[test]
+fn no_binaries_or_examples() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101).with_stderr("\
[ERROR] no packages found with binaries or examples
"));
-});
+}
-test!(no_binaries {
+#[test]
+fn no_binaries() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101).with_stderr("\
[ERROR] specified package has no binaries
"));
-});
+}
-test!(examples {
+#[test]
+fn examples() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
.arg("--example=foo"),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(install_twice {
+#[test]
+fn install_twice() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
binary `foo-bin2[..]` already exists in destination as part of `foo v0.1.0 ([..])`
Add --force to overwrite
"));
-});
+}
-test!(install_force {
+#[test]
+fn install_force() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
foo v0.2.0 ([..]):
foo[..]
"));
-});
+}
-test!(install_force_partial_overlap {
+#[test]
+fn install_force_partial_overlap() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
foo-bin2[..]
foo-bin3[..]
"));
-});
+}
-test!(install_force_bin {
+#[test]
+fn install_force_bin() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
foo v0.2.0 ([..]):
foo-bin2[..]
"));
-});
+}
-test!(compile_failure {
+#[test]
+fn compile_failure() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
To learn more, run the command again with --verbose.
"));
-});
+}
-test!(git_repo {
+#[test]
+fn git_repo() {
let p = git::repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[package]
home = cargo_home().display())));
assert_that(cargo_home(), has_installed_exe("foo"));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(list {
+#[test]
+fn list() {
pkg("foo", "0.0.1");
pkg("bar", "0.2.1");
pkg("bar", "0.2.2");
foo v0.0.1 (registry [..]):
foo[..]
"));
-});
+}
-test!(uninstall_pkg_does_not_exist {
+#[test]
+fn uninstall_pkg_does_not_exist() {
assert_that(cargo_process("uninstall").arg("foo"),
execs().with_status(101).with_stderr("\
[ERROR] package id specification `foo` matched no packages
"));
-});
+}
-test!(uninstall_bin_does_not_exist {
+#[test]
+fn uninstall_bin_does_not_exist() {
pkg("foo", "0.0.1");
assert_that(cargo_process("install").arg("foo"),
execs().with_status(101).with_stderr("\
[ERROR] binary `bar[..]` not installed as part of `foo v0.0.1 ([..])`
"));
-});
+}
-test!(uninstall_piecemeal {
+#[test]
+fn uninstall_piecemeal() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101).with_stderr("\
[ERROR] package id specification `foo` matched no packages
"));
-});
+}
-test!(subcommand_works_out_of_the_box {
+#[test]
+fn subcommand_works_out_of_the_box() {
Package::new("cargo-foo", "1.0.0")
.file("src/main.rs", r#"
fn main() {
execs().with_status(0).with_stdout("bar\n"));
assert_that(cargo_process("--list"),
execs().with_status(0).with_stdout_contains(" foo\n"));
-});
+}
-test!(installs_from_cwd_by_default {
+#[test]
+fn installs_from_cwd_by_default() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(cargo_process("install").cwd(p.root()),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(do_not_rebuilds_on_local_install {
+#[test]
+fn do_not_rebuilds_on_local_install() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert!(p.build_dir().c_exists());
assert!(p.release_bin("foo").c_exists());
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
-test!(reports_unsuccessful_subcommand_result {
+#[test]
+fn reports_unsuccessful_subcommand_result() {
Package::new("cargo-fail", "1.0.0")
.file("src/main.rs", r#"
fn main() {
execs().with_status(101).with_stderr_contains("\
thread '<main>' panicked at 'explicit panic', [..]
"));
-});
+}
-test!(git_with_lockfile {
+#[test]
+fn git_with_lockfile() {
let p = git::repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[package]
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
execs().with_status(0));
-});
+}
-test!(q_silences_warnings {
+#[test]
+fn q_silences_warnings() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(cargo_process("install").arg("-q").arg("--path").arg(p.root()),
execs().with_status(0).with_stderr(""));
-});
+}
-test!(readonly_dir {
+#[test]
+fn readonly_dir() {
pkg("foo", "0.0.1");
let root = paths::root();
assert_that(cargo_process("install").arg("foo").cwd(dir),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
-});
+}
use support::{project, execs, basic_bin_manifest, main_file};
-fn setup() {}
-
-test!(cargo_metadata_simple {
+#[test]
+fn cargo_metadata_simple() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"));
},
"version": 1
}"#));
-});
+}
-test!(cargo_metadata_with_deps_and_version {
+#[test]
+fn cargo_metadata_with_deps_and_version() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
},
"version": 1
}"#));
-});
+}
-test!(cargo_metadata_with_invalid_manifest {
+#[test]
+fn cargo_metadata_with_invalid_manifest() {
let p = project("foo")
.file("Cargo.toml", "");
Caused by:
no `package` or `project` section found."))
-});
+}
const MANIFEST_OUTPUT: &'static str=
r#"
"version": 1
}"#;
-test!(cargo_metadata_no_deps_path_to_cargo_toml_relative {
+#[test]
+fn cargo_metadata_no_deps_path_to_cargo_toml_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
.with_json(MANIFEST_OUTPUT));
-});
+}
-test!(cargo_metadata_no_deps_path_to_cargo_toml_absolute {
+#[test]
+fn cargo_metadata_no_deps_path_to_cargo_toml_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
.with_json(MANIFEST_OUTPUT));
-});
+}
-test!(cargo_metadata_no_deps_path_to_cargo_toml_parent_relative {
+#[test]
+fn cargo_metadata_no_deps_path_to_cargo_toml_parent_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
execs().with_status(101)
.with_stderr("[ERROR] the manifest-path must be \
a path to a Cargo.toml file"));
-});
+}
-test!(cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute {
+#[test]
+fn cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
execs().with_status(101)
.with_stderr("[ERROR] the manifest-path must be \
a path to a Cargo.toml file"));
-});
+}
-test!(cargo_metadata_no_deps_cwd {
+#[test]
+fn cargo_metadata_no_deps_cwd() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root()),
execs().with_status(0)
.with_json(MANIFEST_OUTPUT));
-});
+}
-test!(carg_metadata_bad_version {
+#[test]
+fn carg_metadata_bad_version() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root()),
execs().with_status(101)
.with_stderr("[ERROR] metadata version 2 not supported, only 1 is currently supported"));
-});
+}
use support::{project, execs};
use hamcrest::assert_that;
-fn setup() {}
-
-test!(net_retry_loads_from_config {
+#[test]
+fn net_retry_loads_from_config() {
let p = project("foo")
.file("Cargo.toml", &format!(r#"
[project]
execs().with_status(101)
.with_stderr_contains(&format!("[WARNING] spurious network error \
(1 tries remaining): [2/-1] [..]")));
-});
+}
-test!(net_retry_git_outputs_warning{
+#[test]
+fn net_retry_git_outputs_warning() {
let p = project("foo")
.file("Cargo.toml", &format!(r#"
[project]
(2 tries remaining): [2/-1] [..]"))
.with_stderr_contains(&format!("\
[WARNING] spurious network error (1 tries remaining): [2/-1] [..]")));
-});
+}
use cargo::util::ProcessBuilder;
-fn setup() {
-}
-
fn cargo_process(s: &str) -> ProcessBuilder {
let mut p = ::cargo_process();
p.arg(s);
return p;
}
-test!(simple_lib {
+#[test]
+fn simple_lib() {
assert_that(cargo_process("new").arg("foo").arg("--vcs").arg("none")
.env("USER", "foo"),
execs().with_status(0));
assert_that(cargo_process("build").cwd(&paths::root().join("foo")),
execs().with_status(0));
-});
+}
-test!(simple_bin {
+#[test]
+fn simple_bin() {
assert_that(cargo_process("new").arg("foo").arg("--bin")
.env("USER", "foo"),
execs().with_status(0));
assert_that(&paths::root().join(&format!("foo/target/debug/foo{}",
env::consts::EXE_SUFFIX)),
existing_file());
-});
+}
-test!(simple_git {
+#[test]
+fn simple_git() {
let td = TempDir::new("cargo").unwrap();
assert_that(cargo_process("new").arg("foo").cwd(td.path().clone())
.env("USER", "foo"),
assert_that(cargo_process("build").cwd(&td.path().clone().join("foo")),
execs().with_status(0));
-});
+}
-test!(no_argument {
+#[test]
+fn no_argument() {
assert_that(cargo_process("new"),
execs().with_status(1)
.with_stderr("\
cargo new [options] <path>
cargo new -h | --help
"));
-});
+}
-test!(existing {
+#[test]
+fn existing() {
let dst = paths::root().join("foo");
fs::create_dir(&dst).unwrap();
assert_that(cargo_process("new").arg("foo"),
execs().with_status(101)
.with_stderr(format!("[ERROR] destination `{}` already exists\n",
dst.display())));
-});
+}
-test!(invalid_characters {
+#[test]
+fn invalid_characters() {
assert_that(cargo_process("new").arg("foo.rs"),
execs().with_status(101)
.with_stderr("\
[ERROR] Invalid character `.` in crate name: `foo.rs`
use --name to override crate name"));
-});
+}
-test!(reserved_name {
+#[test]
+fn reserved_name() {
assert_that(cargo_process("new").arg("test"),
execs().with_status(101)
.with_stderr("\
[ERROR] The name `test` cannot be used as a crate name\n\
use --name to override crate name"));
-});
+}
-test!(keyword_name {
+#[test]
+fn keyword_name() {
assert_that(cargo_process("new").arg("pub"),
execs().with_status(101)
.with_stderr("\
[ERROR] The name `pub` cannot be used as a crate name\n\
use --name to override crate name"));
-});
+}
-test!(rust_prefix_stripped {
+#[test]
+fn rust_prefix_stripped() {
assert_that(cargo_process("new").arg("rust-foo").env("USER", "foo"),
execs().with_status(0)
.with_stdout("note: package will be named `foo`; use --name to override"));
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"name = "foo""#));
-});
+}
-test!(bin_disables_stripping {
+#[test]
+fn bin_disables_stripping() {
assert_that(cargo_process("new").arg("rust-foo").arg("--bin").env("USER", "foo"),
execs().with_status(0));
let toml = paths::root().join("rust-foo/Cargo.toml");
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"name = "rust-foo""#));
-});
+}
-test!(explicit_name_not_stripped {
+#[test]
+fn explicit_name_not_stripped() {
assert_that(cargo_process("new").arg("foo").arg("--name").arg("rust-bar").env("USER", "foo"),
execs().with_status(0));
let toml = paths::root().join("foo/Cargo.toml");
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"name = "rust-bar""#));
-});
+}
-test!(finds_author_user {
+#[test]
+fn finds_author_user() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["foo"]"#));
-});
+}
-test!(finds_author_user_escaped {
+#[test]
+fn finds_author_user_escaped() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["foo \"bar\""]"#));
-});
+}
-test!(finds_author_username {
+#[test]
+fn finds_author_username() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["foo"]"#));
-});
+}
-test!(finds_author_priority {
+#[test]
+fn finds_author_priority() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["bar <baz>"]"#));
-});
+}
-test!(finds_author_email {
+#[test]
+fn finds_author_email() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["bar <baz>"]"#));
-});
+}
-test!(finds_author_git {
+#[test]
+fn finds_author_git() {
::process("git").args(&["config", "--global", "user.name", "bar"])
.exec().unwrap();
::process("git").args(&["config", "--global", "user.email", "baz"])
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["bar <baz>"]"#));
-});
+}
-test!(finds_git_email{
+#[test]
+fn finds_git_email() {
let td = TempDir::new("cargo").unwrap();
assert_that(cargo_process("new").arg("foo")
.env("GIT_AUTHOR_NAME", "foo")
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["foo <gitfoo>"]"#), contents);
-});
+}
-test!(finds_git_author{
+#[test]
+fn finds_git_author() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
let mut contents = String::new();
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["gitfoo"]"#));
-});
+}
-test!(author_prefers_cargo {
+#[test]
+fn author_prefers_cargo() {
::process("git").args(&["config", "--global", "user.name", "foo"])
.exec().unwrap();
::process("git").args(&["config", "--global", "user.email", "bar"])
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(r#"authors = ["new-foo <new-bar>"]"#));
assert!(!root.join("foo/.gitignore").c_exists());
-});
+}
-test!(git_prefers_command_line {
+#[test]
+fn git_prefers_command_line() {
let root = paths::root();
let td = TempDir::new("cargo").unwrap();
fs::create_dir(&root.join(".cargo")).unwrap();
.env("USER", "foo"),
execs().with_status(0));
assert!(td.path().join("foo/.gitignore").c_exists());
-});
+}
-test!(subpackage_no_git {
+#[test]
+fn subpackage_no_git() {
assert_that(cargo_process("new").arg("foo").env("USER", "foo"),
execs().with_status(0));
is_not(existing_file()));
assert_that(&paths::root().join("foo/components/subcomponent/.gitignore"),
is_not(existing_file()));
-});
+}
-test!(subpackage_git_with_vcs_arg {
+#[test]
+fn subpackage_git_with_vcs_arg() {
assert_that(cargo_process("new").arg("foo").env("USER", "foo"),
execs().with_status(0));
existing_dir());
assert_that(&paths::root().join("foo/components/subcomponent/.gitignore"),
existing_file());
-});
+}
-test!(unknown_flags {
+#[test]
+fn unknown_flags() {
assert_that(cargo_process("new").arg("foo").arg("--flag"),
execs().with_status(1)
.with_stderr("\
cargo new [..]
cargo new [..]
"));
-});
+}
use support::git;
use support::paths;
-fn setup() {}
-
-test!(override_simple {
+#[test]
+fn override_simple() {
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
[COMPILING] foo v0.1.0 (file://[..])
[COMPILING] local v0.0.1 (file://[..])
"));
-});
+}
-test!(missing_version {
+#[test]
+fn missing_version() {
let p = project("local")
.file("Cargo.toml", r#"
[package]
Caused by:
replacements must specify a version to replace, but `foo` does not
"));
-});
+}
-test!(different_version {
+#[test]
+fn different_version() {
Package::new("foo", "0.2.0").publish();
Package::new("foo", "0.1.0").publish();
Caused by:
replacements cannot specify a version requirement, but found one for [..]
"));
-});
+}
-test!(transitive {
+#[test]
+fn transitive() {
Package::new("foo", "0.1.0").publish();
Package::new("bar", "0.2.0")
.dep("foo", "0.1.0")
"));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
-});
+}
-test!(persists_across_rebuilds {
+#[test]
+fn persists_across_rebuilds() {
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
assert_that(p.cargo("build"),
execs().with_status(0).with_stdout(""));
-});
+}
-test!(replace_registry_with_path {
+#[test]
+fn replace_registry_with_path() {
Package::new("foo", "0.1.0").publish();
project("foo")
[COMPILING] foo v0.1.0 (file://[..])
[COMPILING] local v0.0.1 (file://[..])
"));
-});
+}
-test!(use_a_spec_to_select {
+#[test]
+fn use_a_spec_to_select() {
Package::new("foo", "0.1.1")
.file("src/lib.rs", "pub fn foo1() {}")
.publish();
[COMPILING] [..]
[COMPILING] local v0.0.1 (file://[..])
"));
-});
+}
-test!(override_adds_some_deps {
+#[test]
+fn override_adds_some_deps() {
Package::new("foo", "0.1.1").publish();
Package::new("bar", "0.1.0").publish();
"));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
-});
+}
-test!(locked_means_locked_yes_no_seriously_i_mean_locked {
+#[test]
+fn locked_means_locked_yes_no_seriously_i_mean_locked() {
// this in theory exercises #2041
Package::new("foo", "0.1.0").publish();
Package::new("foo", "0.2.0").publish();
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
-});
+}
-test!(override_wrong_name {
+#[test]
+fn override_wrong_name() {
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
location searched: file://[..]
version required: = 0.1.0
"));
-});
+}
-test!(override_with_nothing {
+#[test]
+fn override_with_nothing() {
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
Caused by:
Could not find Cargo.toml in `[..]`
"));
-});
+}
-test!(override_wrong_version {
+#[test]
+fn override_wrong_version() {
let p = project("local")
.file("Cargo.toml", r#"
[package]
Caused by:
replacements cannot specify a version requirement, but found one for `foo:0.1.0`
"));
-});
+}
-test!(multiple_specs {
+#[test]
+fn multiple_specs() {
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
both specifications match: foo v0.1.0 ([..])
"));
-});
+}
-test!(test_override_dep {
+#[test]
+fn test_override_dep() {
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
[..]#foo:0.1.0
[..]#foo:0.1.0
"));
-});
+}
use support::{project, execs, paths, git, path2url};
use hamcrest::{assert_that, existing_file};
-fn setup() {
-}
-
-test!(simple {
+#[test]
+fn simple() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
fname == b"foo-0.0.1/src/main.rs",
"unexpected filename: {:?}", f.header().path())
}
-});
+}
-test!(metadata_warning {
+#[test]
+fn metadata_warning() {
let p = project("all")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.0.1 ({dir}[..])
",
dir = p.url())));
-});
+}
-test!(package_verbose {
+#[test]
+fn package_verbose() {
let root = paths::root().join("all");
let p = git::repo(&root)
.file("Cargo.toml", r#"
[ARCHIVING] [..]
[ARCHIVING] [..]
"));
-});
+}
-test!(package_verification {
+#[test]
+fn package_verification() {
let p = project("all")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.0.1 ({dir}[..])
",
dir = p.url())));
-});
+}
-test!(exclude {
+#[test]
+fn exclude() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ARCHIVING] [..]
[ARCHIVING] [..]
"));
-});
+}
-test!(include {
+#[test]
+fn include() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ARCHIVING] [..]
[ARCHIVING] [..]
"));
-});
+}
-test!(package_lib_with_bin {
+#[test]
+fn package_lib_with_bin() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("package").arg("-v"),
execs().with_status(0));
-});
+}
-test!(package_new_git_repo {
+#[test]
+fn package_new_git_repo() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ARCHIVING] [..]
[ARCHIVING] [..]
"));
-});
+}
-test!(package_git_submodule {
+#[test]
+fn package_git_submodule() {
let project = git::new("foo", |project| {
project.file("Cargo.toml", r#"
[project]
assert_that(::cargo_process().arg("package").cwd(project.root())
.arg("--no-verify").arg("-v"),
execs().with_status(0).with_stderr_contains("[ARCHIVING] bar/Makefile"));
-});
+}
-test!(no_duplicates_from_modified_tracked_files {
+#[test]
+fn no_duplicates_from_modified_tracked_files() {
let root = paths::root().join("all");
let p = git::repo(&root)
.file("Cargo.toml", r#"
Cargo.toml
src/main.rs
"));
-});
+}
-test!(ignore_nested {
+#[test]
+fn ignore_nested() {
let cargo_toml = r#"
[project]
name = "nested"
fname == b"nested-0.0.1/src/main.rs",
"unexpected filename: {:?}", f.header().path())
}
-});
+}
#[cfg(unix)] // windows doesn't allow these characters in filenames
-test!(package_weird_characters {
+#[test]
+fn package_weird_characters() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
cannot package a filename with a special character `:`: src/:foo
"));
-});
+}
use support::{project, execs};
use hamcrest::assert_that;
-fn setup() {
-}
-
-test!(profile_overrides {
+#[test]
+fn profile_overrides() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
dir = p.root().display(),
url = p.url(),
)));
-});
+}
-test!(top_level_overrides_deps {
+#[test]
+fn top_level_overrides_deps() {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
sep = SEP,
prefix = env::consts::DLL_PREFIX,
suffix = env::consts::DLL_SUFFIX)));
-});
+}
.build();
}
-test!(simple {
+#[test]
+fn simple() {
+ setup();
+
let p = project("foo")
.file("Cargo.toml", r#"
[project]
fname == b"foo-0.0.1/src/main.rs",
"unexpected filename: {:?}", file.header().path());
}
-});
+}
+
+#[test]
+fn git_deps() {
+ setup();
-test!(git_deps {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] all dependencies must come from the same source.
dependency `foo` comes from git://path/to/nowhere instead
"));
-});
+}
+
+#[test]
+fn path_dependency_no_version() {
+ setup();
-test!(path_dependency_no_version {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] all path dependencies must have a version specified when publishing.
dependency `bar` does not specify a version
"));
-});
+}
+
+#[test]
+fn unpublishable_crate() {
+ setup();
-test!(unpublishable_crate {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] some crates cannot be published.
`foo` is marked as unpublishable
"));
-});
+}
use support::{project, execs, main_file, basic_bin_manifest};
use hamcrest::{assert_that};
-fn setup() {}
-
fn remove_all_whitespace(s: &str) -> String {
s.split_whitespace().collect()
}
}"#)
}
-test!(cargo_read_manifest_path_to_cargo_toml_relative {
+#[test]
+fn cargo_read_manifest_path_to_cargo_toml_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
.with_stdout(read_manifest_output()));
-});
+}
-test!(cargo_read_manifest_path_to_cargo_toml_absolute {
+#[test]
+fn cargo_read_manifest_path_to_cargo_toml_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
.with_stdout(read_manifest_output()));
-});
+}
-test!(cargo_read_manifest_path_to_cargo_toml_parent_relative {
+#[test]
+fn cargo_read_manifest_path_to_cargo_toml_parent_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
execs().with_status(101)
.with_stderr("[ERROR] the manifest-path must be \
a path to a Cargo.toml file"));
-});
+}
-test!(cargo_read_manifest_path_to_cargo_toml_parent_absolute {
+#[test]
+fn cargo_read_manifest_path_to_cargo_toml_parent_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
execs().with_status(101)
.with_stderr("[ERROR] the manifest-path must be \
a path to a Cargo.toml file"));
-});
+}
-test!(cargo_read_manifest_cwd {
+#[test]
+fn cargo_read_manifest_cwd() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root()),
execs().with_status(0)
.with_stdout(read_manifest_output()));
-});
+}
use hamcrest::assert_that;
-fn setup() {
-}
-
-test!(simple {
+#[test]
+fn simple() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
",
dir = p.url(),
reg = registry::registry())));
-});
+}
-test!(deps {
+#[test]
+fn deps() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
",
dir = p.url(),
reg = registry::registry())));
-});
+}
-test!(nonexistent {
+#[test]
+fn nonexistent() {
Package::new("init", "0.0.1").publish();
let p = project("foo")
location searched: registry file://[..]
version required: >= 0.0.0
"));
-});
+}
-test!(wrong_version {
+#[test]
+fn wrong_version() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
version required: >= 1.0.0
versions found: 0.0.4, 0.0.3, 0.0.2, ...
"));
-});
+}
-test!(bad_cksum {
+#[test]
+fn bad_cksum() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Caused by:
failed to verify the checksum of `bad-cksum v0.0.1 (registry file://[..])`
"));
-});
+}
-test!(update_registry {
+#[test]
+fn update_registry() {
Package::new("init", "0.0.1").publish();
let p = project("foo")
",
dir = p.url(),
reg = registry::registry())));
-});
+}
-test!(package_with_path_deps {
+#[test]
+fn package_with_path_deps() {
Package::new("init", "0.0.1").publish();
let p = project("foo")
[COMPILING] notyet v0.0.1 (registry file://[..])
[COMPILING] foo v0.0.1 ({dir}[..])
", dir = p.url())));
-});
+}
-test!(lockfile_locks {
+#[test]
+fn lockfile_locks() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo("build"),
execs().with_status(0).with_stdout(""));
-});
+}
-test!(lockfile_locks_transitively {
+#[test]
+fn lockfile_locks_transitively() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo("build"),
execs().with_status(0).with_stdout(""));
-});
+}
-test!(yanks_are_not_used {
+#[test]
+fn yanks_are_not_used() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.0.1 ({dir})
",
dir = p.url())));
-});
+}
-test!(relying_on_a_yank_is_bad {
+#[test]
+fn relying_on_a_yank_is_bad() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
version required: = 0.0.2
versions found: 0.0.1
"));
-});
+}
-test!(yanks_in_lockfiles_are_ok {
+#[test]
+fn yanks_in_lockfiles_are_ok() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
location searched: registry file://[..]
version required: *
"));
-});
+}
-test!(update_with_lockfile_if_packages_missing {
+#[test]
+fn update_with_lockfile_if_packages_missing() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[UPDATING] registry `[..]`
[DOWNLOADING] bar v0.0.1 (registry file://[..])
"));
-});
+}
-test!(update_lockfile {
+#[test]
+fn update_lockfile() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[UPDATING] bar v0.0.4 (registry file://[..]) -> v0.0.5
[REMOVING] spam v0.2.5 (registry file://[..])
"));
-});
+}
-test!(dev_dependency_not_used {
+#[test]
+fn dev_dependency_not_used() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.0.1 ({dir})
",
dir = p.url())));
-});
+}
-test!(login_with_no_cargo_dir {
+#[test]
+fn login_with_no_cargo_dir() {
let home = paths::home().join("new-home");
fs::create_dir(&home).unwrap();
assert_that(::cargo_process().arg("login").arg("foo").arg("-v"),
execs().with_status(0));
-});
+}
-test!(bad_license_file {
+#[test]
+fn bad_license_file() {
Package::new("foo", "1.0.0").publish();
let p = project("all")
.file("Cargo.toml", r#"
execs().with_status(101)
.with_stderr_contains("\
[ERROR] the license file `foo` does not exist"));
-});
+}
-test!(updating_a_dep {
+#[test]
+fn updating_a_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] foo v0.0.1 ({dir})
",
dir = p.url())));
-});
+}
-test!(git_and_registry_dep {
+#[test]
+fn git_and_registry_dep() {
let b = git::repo(&paths::root().join("b"))
.file("Cargo.toml", r#"
[project]
println!("second");
assert_that(p.cargo("build"),
execs().with_status(0).with_stdout(""));
-});
+}
-test!(update_publish_then_update {
+#[test]
+fn update_publish_then_update() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
",
dir = p.url())));
-});
+}
-test!(fetch_downloads {
+#[test]
+fn fetch_downloads() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[UPDATING] registry `[..]`
[DOWNLOADING] a v0.1.0 (registry [..])
"));
-});
+}
-test!(update_transitive_dependency {
+#[test]
+fn update_transitive_dependency() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] a v0.1.0 (registry [..])
[COMPILING] foo v0.5.0 ([..])
"));
-});
+}
-test!(update_backtracking_ok {
+#[test]
+fn update_backtracking_ok() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stderr("\
[UPDATING] registry `[..]`
"));
-});
+}
-test!(update_multiple_packages {
+#[test]
+fn update_multiple_packages() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] c v0.1.1 (registry [..])")
.with_stderr_contains("\
[COMPILING] foo v0.5.0 ([..])"));
-});
+}
-test!(bundled_crate_in_registry {
+#[test]
+fn bundled_crate_in_registry() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.publish();
assert_that(p.cargo("run"), execs().with_status(0));
-});
+}
-test!(update_same_prefix_oh_my_how_was_this_a_bug {
+#[test]
+fn update_same_prefix_oh_my_how_was_this_a_bug() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo("generate-lockfile"), execs().with_status(0));
assert_that(p.cargo("update").arg("-pfoobar").arg("--precise=0.2.0"),
execs().with_status(0));
-});
+}
-test!(use_semver {
+#[test]
+fn use_semver() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
Package::new("foo", "1.2.3-alpha.0").publish();
assert_that(p.cargo("build"), execs().with_status(0));
-});
+}
-test!(only_download_relevant {
+#[test]
+fn only_download_relevant() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[COMPILING] baz v0.1.0 ([..])
[COMPILING] bar v0.5.0 ([..])
"));
-});
+}
-test!(resolve_and_backtracking {
+#[test]
+fn resolve_and_backtracking() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo("build"),
execs().with_status(0));
-});
+}
use support::{project, execs, path2url};
use hamcrest::{assert_that, existing_file};
-fn setup() {
-}
-
-test!(simple {
+#[test]
+fn simple() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
hello
"));
assert_that(&p.bin("foo"), existing_file());
-});
+}
-test!(simple_quiet {
+#[test]
+fn simple_quiet() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
hello
")
);
-});
+}
-test!(simple_quiet_and_verbose {
+#[test]
+fn simple_quiet_and_verbose() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
execs().with_status(101).with_stderr("\
[ERROR] cannot set both --verbose and --quiet
"));
-});
+}
-test!(quiet_and_verbose_config {
+#[test]
+fn quiet_and_verbose_config() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("run").arg("-q"),
execs().with_status(0));
-});
+}
-test!(simple_with_args {
+#[test]
+fn simple_with_args() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("run").arg("hello").arg("world"),
execs().with_status(0));
-});
+}
-test!(exit_code {
+#[test]
+fn exit_code() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[RUNNING] `target[..]`
[ERROR] Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
"));
-});
+}
-test!(exit_code_verbose {
+#[test]
+fn exit_code_verbose() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[RUNNING] `target[..]`
[ERROR] Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
"));
-});
+}
-test!(no_main_file {
+#[test]
+fn no_main_file() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
execs().with_status(101)
.with_stderr("[ERROR] a bin target must be available \
for `cargo run`\n"));
-});
+}
-test!(too_many_bins {
+#[test]
+fn too_many_bins() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stderr("[ERROR] `cargo run` requires that a project only \
have one executable; use the `--bin` option \
to specify which one to run\n"));
-});
+}
-test!(specify_name {
+#[test]
+fn specify_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stdout("\
hello b.rs
"));
-});
+}
-test!(run_example {
+#[test]
+fn run_example() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stdout("\
example
"));
-});
+}
-test!(run_with_filename {
+#[test]
+fn run_with_filename() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
[ERROR] no example target named `a.rs`
Did you mean `a`?"));
-});
+}
-test!(either_name_or_example {
+#[test]
+fn either_name_or_example() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stderr("[ERROR] `cargo run` can run at most one \
executable, but multiple were \
specified"));
-});
+}
-test!(one_bin_multiple_examples {
+#[test]
+fn one_bin_multiple_examples() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stdout("\
hello main.rs
"));
-});
+}
-test!(example_with_release_flag {
+#[test]
+fn example_with_release_flag() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stdout("\
slow1
slow2"));
-});
+}
-test!(run_dylib_dep {
+#[test]
+fn run_dylib_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("run").arg("hello").arg("world"),
execs().with_status(0));
-});
+}
-test!(release_works {
+#[test]
+fn release_works() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
dir = path2url(p.root()),
sep = SEP)));
assert_that(&p.release_bin("foo"), existing_file());
-});
+}
-test!(run_bin_different_name {
+#[test]
+fn run_bin_different_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#);
assert_that(p.cargo_process("run"), execs().with_status(0));
-});
+}
-test!(dashes_are_forwarded {
+#[test]
+fn dashes_are_forwarded() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("run").arg("--").arg("a").arg("--").arg("b"),
execs().with_status(0));
-});
+}
-test!(run_from_executable_folder {
+#[test]
+fn run_from_executable_folder() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.with_stdout("\
hello
"));
-});
+}
use hamcrest::assert_that;
-fn setup() {
-}
-
const CARGO_RUSTC_ERROR: &'static str =
"[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing e.g. `--lib` or `--bin NAME` to specify a single target";
-test!(build_lib_for_foo {
+#[test]
+fn build_lib_for_foo() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
-L dependency={dir}{sep}target{sep}debug{sep}deps`
", sep = SEP,
dir = p.root().display(), url = p.url())));
-});
+}
-test!(lib {
+#[test]
+fn lib() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
-L dependency={dir}{sep}target{sep}debug{sep}deps`
", sep = SEP,
dir = p.root().display(), url = p.url())))
-});
+}
-test!(build_main_and_allow_unstable_options {
+#[test]
+fn build_main_and_allow_unstable_options() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
", sep = SEP,
dir = p.root().display(), url = p.url(),
name = "foo", version = "0.0.1")));
-});
+}
-test!(fails_when_trying_to_build_main_and_lib_with_args {
+#[test]
+fn fails_when_trying_to_build_main_and_lib_with_args() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs()
.with_status(101)
.with_stderr(CARGO_RUSTC_ERROR));
-});
+}
-test!(build_with_args_to_one_of_multiple_binaries {
+#[test]
+fn build_with_args_to_one_of_multiple_binaries() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
-C debug-assertions [..]`
", sep = SEP,
dir = p.root().display(), url = p.url())));
-});
+}
-test!(fails_with_args_to_all_binaries {
+#[test]
+fn fails_with_args_to_all_binaries() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs()
.with_status(101)
.with_stderr(CARGO_RUSTC_ERROR));
-});
+}
-test!(build_with_args_to_one_of_multiple_tests {
+#[test]
+fn build_with_args_to_one_of_multiple_tests() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
-C debug-assertions [..]--test[..]`
", sep = SEP,
dir = p.root().display(), url = p.url())));
-});
+}
-test!(build_foo_with_bar_dependency {
+#[test]
+fn build_foo_with_bar_dependency() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
[RUNNING] `[..] -g -C debug-assertions [..]`
",
url = foo.url())));
-});
+}
-test!(build_only_bar_dependency {
+#[test]
+fn build_only_bar_dependency() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
[COMPILING] bar v0.1.0 ([..])
[RUNNING] `[..]--crate-name bar --crate-type lib [..] -C debug-assertions [..]`
"));
-});
+}
-test!(fail_with_multiple_packages {
+#[test]
+fn fail_with_multiple_packages() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Usage:
cargo rustc [options] [--] [<opts>...]"));
-});
+}
-test!(rustc_with_other_profile {
+#[test]
+fn rustc_with_other_profile() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(foo.cargo("rustc").arg("--profile").arg("test"),
execs().with_status(0));
-});
+}
use support::{execs, project};
use hamcrest::{assert_that};
-fn setup() {
-}
-
-
-test!(rustdoc_simple {
+#[test]
+fn rustdoc_simple() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
-L dependency={dir}{sep}target{sep}debug{sep}deps`
", sep = SEP,
dir = p.root().display(), url = p.url())));
-});
+}
-test!(rustdoc_args {
+#[test]
+fn rustdoc_args() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
-L dependency={dir}{sep}target{sep}debug{sep}deps`
", sep = SEP,
dir = p.root().display(), url = p.url())));
-});
+}
-test!(rustdoc_foo_with_bar_dependency {
+#[test]
+fn rustdoc_foo_with_bar_dependency() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
--extern [..]`
", sep = SEP,
dir = foo.root().display(), url = foo.url())));
-});
+}
-test!(rustdoc_only_bar_dependency {
+#[test]
+fn rustdoc_only_bar_dependency() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
-L dependency={dir}{sep}target{sep}debug{sep}deps`
", sep = SEP,
dir = foo.root().display())));
-});
+}
-test!(rustdoc_same_name_err {
+#[test]
+fn rustdoc_same_name_err() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
.with_stderr("[ERROR] cannot document a package where a library and a \
binary have the same name. Consider renaming one \
or marking the target as `doc = false`"));
-});
+}
return b
}
-test!(simple {
+#[test]
+fn simple() {
+ setup();
+
let contents = r#"{
"crates": [{
"created_at": "2014-11-16T20:17:35Z",
[UPDATING] registry `[..]`")
.with_stdout("\
hoare (0.1.1) Design by contract style assertions for Rust"));
-});
+}
+
+#[test]
+fn multiple_query_params() {
+ setup();
-test!(multiple_query_params {
let contents = r#"{
"crates": [{
"created_at": "2014-11-16T20:17:35Z",
[UPDATING] registry `[..]`")
.with_stdout("\
hoare (0.1.1) Design by contract style assertions for Rust"));
-});
+}
-test!(help {
+#[test]
+fn help() {
assert_that(cargo_process("search").arg("-h"),
execs().with_status(0));
assert_that(cargo_process("help").arg("search"),
execs().with_status(0));
-});
+}
use hamcrest::{assert_that, existing_file, is_not};
use cargo::util::process;
-fn setup() {}
-
-test!(cargo_test_simple {
+#[test]
+fn cargo_test_simple() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", r#"
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(cargo_test_release {
+#[test]
+fn cargo_test_release() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(cargo_test_verbose {
+#[test]
+fn cargo_test_verbose() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", r#"
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(many_similar_names {
+#[test]
+fn many_similar_names() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert!(output.contains("test bin_test"), "bin_test missing\n{}", output);
assert!(output.contains("test lib_test"), "lib_test missing\n{}", output);
assert!(output.contains("test test_test"), "test_test missing\n{}", output);
-});
+}
-test!(cargo_test_failing_test {
+#[test]
+fn cargo_test_failing_test() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", r#"
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
")
.with_status(101));
-});
+}
-test!(test_with_lib_dep {
+#[test]
+fn test_with_lib_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"))
-});
+}
-test!(test_with_deep_lib_dep {
+#[test]
+fn test_with_deep_lib_dep() {
let p = project("bar")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(external_test_explicit {
+#[test]
+fn external_test_explicit() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"))
-});
+}
-test!(external_test_implicit {
+#[test]
+fn external_test_implicit() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"))
-});
+}
-test!(dont_run_examples {
+#[test]
+fn dont_run_examples() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#);
assert_that(p.cargo_process("test"),
execs().with_status(0));
-});
+}
-test!(pass_through_command_line {
+#[test]
+fn pass_through_command_line() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
// Regression test for running cargo-test twice with
// tests in an rlib
-test!(cargo_test_twice {
+#[test]
+fn cargo_test_twice() {
let p = project("test_twice")
.file("Cargo.toml", &basic_lib_manifest("test_twice"))
.file("src/test_twice.rs", r#"
assert_that(p.cargo("test"),
execs().with_status(0));
}
-});
+}
-test!(lib_bin_same_name {
+#[test]
+fn lib_bin_same_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"))
-});
+}
-test!(lib_with_standard_name {
+#[test]
+fn lib_with_standard_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(lib_with_standard_name2 {
+#[test]
+fn lib_with_standard_name2() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(lib_without_name {
+#[test]
+fn lib_without_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(bin_without_name {
+#[test]
+fn bin_without_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
binary target bin.name is required"));
-});
+}
-test!(bench_without_name {
+#[test]
+fn bench_without_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
bench target bench.name is required"));
-});
+}
-test!(test_without_name {
+#[test]
+fn test_without_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
test target test.name is required"));
-});
+}
-test!(example_without_name {
+#[test]
+fn example_without_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
Caused by:
example target example.name is required"));
-});
+}
-test!(bin_there_for_integration {
+#[test]
+fn bin_there_for_integration() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
let output = str::from_utf8(&output.stdout).unwrap();
assert!(output.contains("main_test ... ok"), "no main_test\n{}", output);
assert!(output.contains("test_test ... ok"), "no test_test\n{}", output);
-});
+}
-test!(test_dylib {
+#[test]
+fn test_dylib() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
"));
-});
+}
-test!(test_twice_with_build_cmd {
+#[test]
+fn test_twice_with_build_cmd() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(test_then_build {
+#[test]
+fn test_then_build() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("build"),
execs().with_status(0)
.with_stdout(""));
-});
+}
-test!(test_no_run {
+#[test]
+fn test_no_run() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[COMPILING] foo v0.0.1 ({dir})
",
dir = p.url())));
-});
+}
-test!(test_run_specific_bin_target {
+#[test]
+fn test_run_specific_bin_target() {
let prj = project("foo")
.file("Cargo.toml" , r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(test_run_specific_test_target {
+#[test]
+fn test_run_specific_test_target() {
let prj = project("foo")
.file("Cargo.toml" , r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(test_no_harness {
+#[test]
+fn test_no_harness() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[RUNNING] target[..]bar-[..]
",
dir = p.url())));
-});
+}
-test!(selective_testing {
+#[test]
+fn selective_testing() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(almost_cyclic_but_not_quite {
+#[test]
+fn almost_cyclic_but_not_quite() {
let p = project("a")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(p.cargo("test"),
execs().with_status(0));
-});
+}
-test!(build_then_selective_test {
+#[test]
+fn build_then_selective_test() {
let p = project("a")
.file("Cargo.toml", r#"
[package]
p.root().move_into_the_past().unwrap();
assert_that(p.cargo("test").arg("-p").arg("b"),
execs().with_status(0));
-});
+}
-test!(example_dev_dep {
+#[test]
+fn example_dev_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo("run")
.arg("--example").arg("e1").arg("--release").arg("-v"),
execs().with_status(0));
-});
+}
-test!(selective_testing_with_docs {
+#[test]
+fn selective_testing_with_docs() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(example_bin_same_name {
+#[test]
+fn example_bin_same_name() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
bin
"));
assert_that(&p.bin("foo"), existing_file());
-});
+}
-test!(test_with_example_twice {
+#[test]
+fn test_with_example_twice() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
assert_that(&p.bin("examples/foo"), existing_file());
-});
+}
-test!(example_with_dev_dep {
+#[test]
+fn example_with_dev_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[..]
[RUNNING] `rustc [..] --crate-name ex [..] --extern a=[..]`
"));
-});
+}
-test!(bin_is_preserved {
+#[test]
+fn bin_is_preserved() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
-});
+}
-test!(bad_example {
+#[test]
+fn bad_example() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
execs().with_status(101).with_stderr("\
[ERROR] no bin target named `foo`
"));
-});
+}
-test!(doctest_feature {
+#[test]
+fn doctest_feature() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"))
-});
+}
-test!(dashes_to_underscores {
+#[test]
+fn dashes_to_underscores() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
-});
+}
-test!(doctest_dev_dep {
+#[test]
+fn doctest_dev_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
-});
+}
-test!(filter_no_doc_tests {
+#[test]
+fn filter_no_doc_tests() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(dylib_doctest {
+#[test]
+fn dylib_doctest() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(dylib_doctest2 {
+#[test]
+fn dylib_doctest2() {
// can't doctest dylibs as they're statically linked together
let p = project("foo")
.file("Cargo.toml", r#"
assert_that(p.cargo_process("test"),
execs().with_stdout(""));
-});
+}
-test!(cyclic_dev_dep_doc_test {
+#[test]
+fn cyclic_dev_dep_doc_test() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"))
-});
+}
-test!(dev_dep_with_build_script {
+#[test]
+fn dev_dep_with_build_script() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
.file("bar/build.rs", "fn main() {}");
assert_that(p.cargo_process("test"),
execs().with_status(0));
-});
+}
-test!(no_fail_fast {
+#[test]
+fn no_fail_fast() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
"))
-});
+}
-test!(test_multiple_packages {
+#[test]
+fn test_multiple_packages() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
"));
-});
+}
-test!(bin_does_not_rebuild_tests {
+#[test]
+fn bin_does_not_rebuild_tests() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[RUNNING] `rustc src[..]main.rs [..]`
[RUNNING] `rustc src[..]main.rs [..]`
"));
-});
+}
-test!(selective_test_wonky_profile {
+#[test]
+fn selective_test_wonky_profile() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
assert_that(p.cargo("test").arg("-v").arg("--no-run").arg("--release")
.arg("-p").arg("foo").arg("-p").arg("a"),
execs().with_status(0));
-});
+}
-test!(selective_test_optional_dep {
+#[test]
+fn selective_test_optional_dep() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
[RUNNING] `rustc a[..]src[..]lib.rs [..]`
[RUNNING] `rustc a[..]src[..]lib.rs [..]`
"));
-});
+}
-test!(only_test_docs {
+#[test]
+fn only_test_docs() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
test result: ok.[..]
"));
-});
+}
-test!(test_panic_abort_with_dep {
+#[test]
+fn test_panic_abort_with_dep() {
if !::is_nightly() {
return
}
.file("bar/src/lib.rs", "");
assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
-});
+}
use support::{path2url, project, execs};
use hamcrest::assert_that;
-fn setup() {
-}
-
-test!(pathless_tools {
+#[test]
+fn pathless_tools() {
let target = ::rustc_host();
let foo = project("foo")
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]`
", url = foo.url())))
-});
+}
-test!(absolute_tools {
+#[test]
+fn absolute_tools() {
let target = ::rustc_host();
// Escaped as they appear within a TOML config file
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..] -C ar={ar} -C linker={linker} [..]`
", url = foo.url(), ar = output.0, linker = output.1)))
-});
+}
-test!(relative_tools {
+#[test]
+fn relative_tools() {
let target = ::rustc_host();
// Escaped as they appear within a TOML config file
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..] -C ar={ar} -C linker={linker} [..]`
", url = foo_url, ar = output.0, linker = output.1)))
-});
+}
use support::{project, execs, main_file, basic_bin_manifest};
use hamcrest::{assert_that};
-fn setup() {}
-
fn verify_project_success_output() -> String {
r#"{"success":"true"}"#.into()
}
-test!(cargo_verify_project_path_to_cargo_toml_relative {
+#[test]
+fn cargo_verify_project_path_to_cargo_toml_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
.with_stdout(verify_project_success_output()));
-});
+}
-test!(cargo_verify_project_path_to_cargo_toml_absolute {
+#[test]
+fn cargo_verify_project_path_to_cargo_toml_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
.with_stdout(verify_project_success_output()));
-});
+}
-test!(cargo_verify_project_cwd {
+#[test]
+fn cargo_verify_project_cwd() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
.cwd(p.root()),
execs().with_status(0)
.with_stdout(verify_project_success_output()));
-});
+}
use hamcrest::assert_that;
use cargo;
-fn setup() {}
-
-test!(simple {
+#[test]
+fn simple() {
let p = project("foo");
assert_that(p.cargo_process("version"),
execs().with_status(0).with_stdout(&format!("{}\n",
cargo::version())));
-});
+}
#[derive(RustcDecodable)]
struct FooFlags {
}
}
-test!(subcommand_with_version_using_exec_main_without_stdin {
+#[test]
+fn subcommand_with_version_using_exec_main_without_stdin() {
let usage = "
Usage: cargo foo [--version]
real_main, &cargo::Config::default().unwrap(),
usage, &args, false);
assert_eq!(result.unwrap(), Some("foo <version>".to_string()));
-});
+}
use support::{Tap, execs, shell_writes};
-fn setup() {
-}
-
struct Sink(Arc<Mutex<Vec<u8>>>);
impl Write for Sink {
fn flush(&mut self) -> io::Result<()> { Ok(()) }
}
-test!(non_tty {
+#[test]
+fn non_tty() {
let config = ShellConfig { color_config: Auto, tty: false };
let a = Arc::new(Mutex::new(Vec::new()));
});
let buf = a.lock().unwrap().clone();
assert_that(&buf[..], shell_writes("Hey Alex\n"));
-});
+}
-test!(color_explicitly_disabled {
+#[test]
+fn color_explicitly_disabled() {
let term = TerminfoTerminal::new(Vec::new());
if term.is_none() { return }
});
let buf = a.lock().unwrap().clone();
assert_that(&buf[..], shell_writes("Hey Alex\n"));
-});
+}
-test!(colored_shell {
+#[test]
+fn colored_shell() {
let term = TerminfoTerminal::new(Vec::new());
if term.is_none() { return }
assert_that(&buf[..],
shell_writes(colored_output("Hey Alex\n",
color::RED).unwrap()));
-});
+}
-test!(color_explicitly_enabled {
+#[test]
+fn color_explicitly_enabled() {
let term = TerminfoTerminal::new(Vec::new());
if term.is_none() { return }
assert_that(&buf[..],
shell_writes(colored_output("Hey Alex\n",
color::RED).unwrap()));
-});
+}
-test!(no_term {
+#[test]
+fn no_term() {
// Verify that shell creation is successful when $TERM does not exist.
assert_that(::cargo_process().env_remove("TERM"),
execs().with_stderr(""));
-});
+}
fn colored_output(string: &str, color: color::Color) -> CargoResult<String> {
let mut term = TerminfoTerminal::new(Vec::new()).unwrap();
use std::time::Duration;
mod support;
-macro_rules! test {
- ($name:ident $expr:expr) => (
- #[test]
- fn $name() {
- ::support::paths::setup();
- setup();
- $expr;
- }
- )
-}
mod test_bad_config;
mod test_bad_manifest_path;